From 56e849837bbef9c33dc4655d7624825b77bac9da Mon Sep 17 00:00:00 2001 From: Emmanuel Gomez Date: Thu, 30 Sep 2010 15:45:33 -0700 Subject: [PATCH] Fixed mass-assignment issue in AssociationCollection [#5738 state:resolved]. Small patch that circumvents MassAssignmentSecurity when updating the attributes of in-memory AR instances from the collection load query. --- .../associations/association_collection.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index a617a0f..0c86751 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -399,7 +399,7 @@ module ActiveRecord if i @target.delete_at(i).tap do |t| keys = ["id"] + t.changes.keys + (f.attribute_names - t.attribute_names) - t.attributes = f.attributes.except(*keys) + t.send(:attributes=, f.attributes.except(*keys), false) end else f -- 1.7.3.1