From e646d3bf574ad3ea7dc5b525511377559b2640dc Mon Sep 17 00:00:00 2001 From: Shintaro Kojima Date: Sat, 4 Apr 2015 12:24:48 +0000 Subject: Fix a regression introduced by removing unnecessary db call when replacing When replacing a has_many association with the same one, there is nothing to do with database but a setter method should still return the substituted value for backward compatibility. --- activerecord/lib/active_record/associations/collection_association.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activerecord/lib/active_record/associations') diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 88531205a1..6caadb4ce8 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -370,6 +370,8 @@ module ActiveRecord replace_common_records_in_memory(other_array, original_target) if other_array != original_target transaction { replace_records(other_array, original_target) } + else + other_array end end end -- cgit v1.2.3