diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-11 12:18:57 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-11 12:18:57 -0700 |
commit | 2a0f2603d18064a1997b5c31a07b0e17edb1fbf5 (patch) | |
tree | 09a618fc4c80e5dff3215b81e7ede5144a8b52dc /activerecord/lib | |
parent | 802876854d23e7735c8647e0a7b90440db095d8a (diff) | |
parent | 5cbed2bc606750c71ee231d2b816471fe241459e (diff) | |
download | rails-2a0f2603d18064a1997b5c31a07b0e17edb1fbf5.tar.gz rails-2a0f2603d18064a1997b5c31a07b0e17edb1fbf5.tar.bz2 rails-2a0f2603d18064a1997b5c31a07b0e17edb1fbf5.zip |
Merge pull request #12194 from thedarkone/readonly-merger-fix
Relation#merge should not lose readonly(false) flag.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/merger.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb index 530c47d0d0..c05632e688 100644 --- a/activerecord/lib/active_record/relation/merger.rb +++ b/activerecord/lib/active_record/relation/merger.rb @@ -58,7 +58,11 @@ module ActiveRecord def merge normal_values.each do |name| value = values[name] - relation.send("#{name}!", *value) unless value.blank? + # The unless clause is here mostly for performance reasons (since the `send` call might be moderately + # expensive), most of the time the value is going to be `nil` or `.blank?`, the only catch is that + # `false.blank?` returns `true`, so there needs to be an extra check so that explicit `false` values + # don't fall through the cracks. + relation.send("#{name}!", *value) unless value.nil? || (value.blank? && false != value) end merge_multi_values |