aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/association_collection.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-01-09 16:34:23 +0000
committerAaron Patterson <aaron.patterson@gmail.com>2011-01-11 13:45:07 -0800
commit6055bbedaa4b7b4bb2377ac87147196eebb2edc1 (patch)
tree0c7fb7848c25eed7d0ec9dd880f755c3b4e6cd3b /activerecord/lib/active_record/associations/association_collection.rb
parent1d6e2184283d15d20ed3102ca462d905e5efa73d (diff)
downloadrails-6055bbedaa4b7b4bb2377ac87147196eebb2edc1.tar.gz
rails-6055bbedaa4b7b4bb2377ac87147196eebb2edc1.tar.bz2
rails-6055bbedaa4b7b4bb2377ac87147196eebb2edc1.zip
Raise ActiveRecord::RecordNotSaved if an AssociationCollection fails to be replaced
Diffstat (limited to 'activerecord/lib/active_record/associations/association_collection.rb')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index daec8493ac..3d8a23fdca 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -314,7 +314,11 @@ module ActiveRecord
transaction do
delete(@target - other_array)
- concat(other_array - @target)
+
+ unless concat(other_array - @target)
+ raise RecordNotSaved, "Failed to replace #{@reflection.name} because one or more of the "
+ "new records could not be saved."
+ end
end
end