aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | | | Merge pull request #20989 from matthewd/no-lock-basic-requireMatthew Draper2015-07-231-6/+4
|\ \ \ \ \ \ \ | |_|_|/ / / / |/| | | | | | Don't apply locking around basic #load / #require
| * | | | | | Don't apply locking around basic #load / #requireMatthew Draper2015-07-231-6/+4
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | That's outside our remit, and dangerous... if a caller has their own locking to protect against the natural race danger, we'll deadlock against it.
* | | | | | rm `deep_munge`. You will live on in our hearts (and git history)Aaron Patterson2015-07-213-26/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we have encoding strategies, we can just walk the params hash once to encode as HWIA, and remove nils.
* | | | | | push param encoding in to the utils moduleAaron Patterson2015-07-212-14/+30
| | | | | | | | | | | | | | | | | | | | | | | | we'll refactor deep munge mostly out of existence shortly
* | | | | | stop keeping track of keys when "deep munging"Aaron Patterson2015-07-211-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | This should have been done along with 8f8ccb9901cab457c6e1d52bdb25acf658fd5777
* | | | | | recurse for arrays in `normalize_encode_params`Aaron Patterson2015-07-211-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this just pushes the conditional in to the case / when so we can switch to method dispatch later
* | | | | | drop conditionals in conversion logicAaron Patterson2015-07-211-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there is no reason to `convert_hashes_to_parameters` with an assignemt flag. The caller knows whether or not it wants the value assigned. We should just change the uncommon case (not writing to the underlying hash) to just call the conversion method and return that value.
* | | | | | rearrange logic to use positive branchesAaron Patterson2015-07-211-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | only hashes are converted to parameter objects, so lets add a branch for them. This also removes a is_a? test for Parameters so we can be abstracted from the class.
* | | | | | Merge pull request #20973 from vngrs/fix_rails_testsRafael Mendonça França2015-07-211-1/+1
|\ \ \ \ \ \ | |_|_|_|/ / |/| | | | | fix rails tests
| * | | | | fix rails testsMehmet Emin İNAÇ2015-07-211-1/+1
|/ / / / /
* | | | | Merge pull request #20967 from lxsameer/record_not_foundRafael Mendonça França2015-07-215-5/+35
|\ \ \ \ \ | | | | | | | | | | | | Extra caller details added to ActiveRecord::RecordNotFound
| * | | | | Extra caller details added to ActiveRecord::RecordNotFoundSameer Rahmani2015-07-215-5/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ActiveRecord::RecordNotFound modified to store model name, primary_key and id of the caller model. It allows the catcher of this exception to make a better decision to what to do with it. For example consider this simple example: class SomeAbstractController < ActionController::Base rescue_from ActiveRecord::RecordNotFound, with: :redirect_to_404 private def redirect_to_404(e) return redirect_to(posts_url) if e.model == 'Post' raise end end
* | | | | | Merge pull request #20926 from rsanheim/fail-fast-bin-setupRafael Mendonça França2015-07-211-5/+9
|\ \ \ \ \ \ | | | | | | | | | | | | | | add system! to fail fast in bin/setup
| * | | | | | add system! to fail fast in bin/setupRob Sanheim2015-07-181-5/+9
| | | | | | |
* | | | | | | Merge pull request #20819 from y-yagi/rails_api_gemfileRafael Mendonça França2015-07-212-1/+4
|\ \ \ \ \ \ \ | |_|/ / / / / |/| | | | | | remove `web-console` from API app generated Gemfile
| * | | | | | remove `web-console` from API app generated Gemfileyuuji.yaginuma2015-07-092-1/+4
| | | | | | |
* | | | | | | Merge pull request #20668 from ↵Rafael Mendonça França2015-07-216-4/+73
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | repinel/rename-restrict-dependent-destroy-i18n-key Deprecate the keys for association `restrict_dependent_destroy` errors in favor of new key names
| * | | | | | | Deprecate and rename the keys for association restrict_dependent_destroyRoque Pinel2015-07-206-4/+73
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously `has_one` and `has_many` associations were using the `one` and `many` keys respectively. Both of these keys have special meaning in I18n (they are considered to be pluralizations) so by renaming them to `has_one` and `has_many` we make the messages more explicit and most importantly they don't clash with linguistical systems that need to validate translation keys (and their pluralizations). The `:'restrict_dependent_destroy.one'` key should be replaced with `:'restrict_dependent_destroy.has_one'`, and `:'restrict_dependent_destroy.many'` with `:'restrict_dependent_destroy.has_many'`. [Roque Pinel & Christopher Dell]
* | | | | | | Merge pull request #20732 from jorihardman/timestamp_precison2Sean Griffin2015-07-206-18/+62
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Ensure that microsecond precision is only used for versions of mysql that support it.
| * | | | | | | Ensure that microsecond precision is only used for version of mysql that ↵Jori Hardman2015-07-206-18/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | support it. Fixes #19711
* | | | | | | | Merge pull request #20751 from repinel/remove-unnecessary-dupRafael Mendonça França2015-07-201-1/+1
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Remove unnecessary `dup` from Mapper `add_route`
| * | | | | | | | Remove unnecessary `dup` from Mapper `add_route`Roque Pinel2015-07-011-1/+1
| | |_|_|_|_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `dup` was introduced by c4106d0c08954b0761726e0015ec601b7bc7ea4b to work around a frozen key. Nowadays, the string is already being duplicated by the `tr` in `options[:action] ||= action.tr('-', '_')` and later joined into a new string in `name_for_action`.
* | | | | | | | Merge pull request #17109 from thejamespinto/patch-1Rafael Mendonça França2015-07-201-1/+1
|\ \ \ \ \ \ \ \ | |_|/ / / / / / |/| | | | | | | titleizing the New Link
| * | | | | | | titleizing the New LinkThiago Pinto2015-07-201-1/+1
|/ / / / / / /
* | | | | | | Merge pull request #20956 from djpowers/patch-1Sean Griffin2015-07-201-1/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Fix minor typo in testing guide [ci skip]
| * | | | | | | Fix minor typo in testing guideDave Powers2015-07-201-1/+1
|/ / / / / / / | | | | | | | | | | | | | | [ci skip]
* | | | | | | Fix minor typo in test nameSean Griffin2015-07-201-1/+1
| | | | | | |
* | | | | | | Merge pull request #20947Sean Griffin2015-07-204-1/+26
|\ \ \ \ \ \ \
| * | | | | | | Fix state being carried over from previous transactionRoque Pinel2015-07-204-1/+26
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This clears the transaction record state when the transaction finishes with a `:committed` status. Considering the following example where `name` is a required attribute. Before we had `new_record?` returning `true` for a persisted record: ```ruby author = Author.create! name: 'foo' author.name = nil author.save # => false author.new_record? # => true ```
* | | | | | | Correctly ignore `mark_for_destruction` without `autosave`Sean Griffin2015-07-204-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As per the docs, `mark_for_destruction` should do nothing if `autosave` is not set to true. We normally persist associations on a record no matter what if the record is a new record, but we were always skipping records which were `marked_for_destruction?`. Fixes #20882
* | | | | | | Merge pull request #20949 from vngrs/missing_method_in_exceptionSean Griffin2015-07-201-1/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Add missing method name to exception description
| * | | | | | | Add missing method name to exception descriptionMehmet Emin İNAÇ2015-07-201-1/+1
| | |_|_|/ / / | |/| | | | |
* | | | | | | Merge pull request #20950 from vngrs/fix_wrong_doc_about_transactionSean Griffin2015-07-201-2/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | fix doc about ActiveRecord::Transactions::ClassMethods#transaction [ci skip]
| * | | | | | | fix doc about ActiveRecord::Transactions::ClassMethods#transaction [ci skip]Mehmet Emin İNAÇ2015-07-201-2/+1
| |/ / / / / /
* | | | | | | Merge pull request #20895 from brian-davis/brian-davisSean Griffin2015-07-201-1/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | grammar fix to content_for method documentation in capture_helper.rb [ci skip]
| * | | | | | | grammar fix to content_for method documentation in capture_helper.rbBrian Davis2015-07-151-1/+1
| | | | | | | |
* | | | | | | | Merge pull request #20384 from kaspth/per-request-cacheDavid Heinemeier Hansson2015-07-204-17/+82
|\ \ \ \ \ \ \ \ | |_|/ / / / / / |/| | | | | | | Use digest cache in development.
| * | | | | | | Remove unused persistent option.Kasper Timm Hansen2015-07-181-3/+3
| | | | | | | |
| * | | | | | | Make digest cache work in development.Kasper Timm Hansen2015-07-184-14/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid computing the same fragment digest many times when looping over templates. The cache is cleared on every request so template changes are still picked up.
* | | | | | | | Fix tests broken by previous commitSean Griffin2015-07-191-1/+1
| | | | | | | |
* | | | | | | | Merge pull request #20946 from schneems/schneems/let-it-goSean Griffin2015-07-1932-60/+60
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Freeze string literals when not mutated.
| * | | | | | | | Freeze string literals when not mutated.schneems2015-07-1932-60/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I wrote a utility that helps find areas where you could optimize your program using a frozen string instead of a string literal, it's called [let_it_go](https://github.com/schneems/let_it_go). After going through the output and adding `.freeze` I was able to eliminate the creation of 1,114 string objects on EVERY request to [codetriage](codetriage.com). How does this impact execution? To look at memory: ```ruby require 'get_process_mem' mem = GetProcessMem.new GC.start GC.disable 1_114.times { " " } before = mem.mb after = mem.mb GC.enable puts "Diff: #{after - before} mb" ``` Creating 1,114 string objects results in `Diff: 0.03125 mb` of RAM allocated on every request. Or 1mb every 32 requests. To look at raw speed: ```ruby require 'benchmark/ips' number_of_objects_reduced = 1_114 Benchmark.ips do |x| x.report("freeze") { number_of_objects_reduced.times { " ".freeze } } x.report("no-freeze") { number_of_objects_reduced.times { " " } } end ``` We get the results ``` Calculating ------------------------------------- freeze 1.428k i/100ms no-freeze 609.000 i/100ms ------------------------------------------------- freeze 14.363k (± 8.5%) i/s - 71.400k no-freeze 6.084k (± 8.1%) i/s - 30.450k ``` Now we can do some maths: ```ruby ips = 6_226k # iterations / 1 second call_time_before = 1.0 / ips # seconds per iteration ips = 15_254 # iterations / 1 second call_time_after = 1.0 / ips # seconds per iteration diff = call_time_before - call_time_after number_of_objects_reduced * diff * 100 # => 0.4530373333993266 miliseconds saved per request ``` So we're shaving off 1 second of execution time for every 220 requests. Is this going to be an insane speed boost to any Rails app: nope. Should we merge it: yep. p.s. If you know of a method call that doesn't modify a string input such as [String#gsub](https://github.com/schneems/let_it_go/blob/b0e2da69f0cca87ab581022baa43291cdf48638c/lib/let_it_go/core_ext/string.rb#L37) please [give me a pull request to the appropriate file](https://github.com/schneems/let_it_go/blob/b0e2da69f0cca87ab581022baa43291cdf48638c/lib/let_it_go/core_ext/string.rb#L37), or open an issue in LetItGo so we can track and freeze more strings. Keep those strings Frozen ![](https://www.dropbox.com/s/z4dj9fdsv213r4v/let-it-go.gif?dl=1)
* | | | | | | | | Merge pull request #20936 from repinel/fix-params-fetch-exception-overwrittenSean Griffin2015-07-193-3/+25
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | Fix exception overwritten for parameters fetch method
| * | | | | | | | | Fix exception overwritten for parameters fetch methodRoque Pinel2015-07-183-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When executing an `ActionController::Parameters#fetch` with a block that raises a `KeyError` the raised `KeyError` will be rescued and converted to an `ActionController::ParameterMissing` exception, covering up the original exception. [Jonas Schubert Erlandsson & Roque Pinel]
* | | | | | | | | | Merge Pull Request #16445Sean Griffin2015-07-196-5/+35
|\ \ \ \ \ \ \ \ \ \
| * | | | | | | | | | Fix the test that was broken by #16445 rather than deleting itSean Griffin2015-07-191-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the counter cache was properly being updated, the model became stale. Simply reloading the model before attempting to destroy is sufficient for this case. I believe this is enough of an edge case to be a valid change to the tests, even though it represents a potential breaking change.
| * | | | | | | | | | Fix counter_cache for polymorphic associationsStefan Kanev2015-07-196-16/+34
|/ / / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also removes a false positive test that depends on the fixed bug: At this time, counter_cache does not work with polymorphic relationships (which is a bug). The test was added to make sure that no StaleObjectError is raised when the car is destroyed. No such error is currently raised because the lock version is not incremented by appending a wheel to the car. Furthermore, `assert_difference` succeeds because `car.wheels.count` does not check the counter cache, but the collection size. The test will fail if it is replaced with `car.wheels_count || 0`.
* | | | | | | | | | Merge pull request #20944 from repinel/fix-time-with-zone-eqlKasper Timm Hansen2015-07-193-1/+13
|\ \ \ \ \ \ \ \ \ \ | |_|/ / / / / / / / |/| | | | | | | | | Fix `TimeWithZone#eql?` to handle `TimeWithZone` created from `DateTime`
| * | | | | | | | | Fix `TimeWithZone#eql?` to handle `TimeWithZone` created from `DateTime`Roque Pinel2015-07-193-1/+13
| |/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ```ruby twz = DateTime.now.in_time_zone twz.eql?(twz.dup) => false ``` Now: ```ruby twz = DateTime.now.in_time_zone twz.eql?(twz.dup) => true ``` Please notice that this fix the `TimeWithZone` comparison to itself, not to `DateTime`. Based on #3725, `DateTime` should not be equal to `TimeWithZone`.
* | | | | | | | | Merge pull request #20931 from eliotsykes/force_ssl-docs-options-formattingKasper Timm Hansen2015-07-191-6/+6
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | Fix formatting of force_ssl options documentation [ci skip]