aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2014-03-01 12:03:23 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2014-03-01 12:03:23 -0200
commitf60b5249194d71a5a7ad152332400af39543628f (patch)
tree48334f0fec1316bfb88e74561f65421d256f9ff8 /activerecord/lib/active_record
parentf1601073de55deb78d041645e74b04c4969345d7 (diff)
parent774160b9ad6908435bf3485e7ac98633deff76c6 (diff)
downloadrails-f60b5249194d71a5a7ad152332400af39543628f.tar.gz
rails-f60b5249194d71a5a7ad152332400af39543628f.tar.bz2
rails-f60b5249194d71a5a7ad152332400af39543628f.zip
Merge pull request #14234 from arthurnn/fix_trans_on_replace
Remove unnecessary db call when replacing.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 270871c866..9a2900843e 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -359,7 +359,9 @@ module ActiveRecord
if owner.new_record?
replace_records(other_array, original_target)
else
- transaction { replace_records(other_array, original_target) }
+ if other_array != original_target
+ transaction { replace_records(other_array, original_target) }
+ end
end
end