From e6b6d3adaddae971a1ba5a1a6bfef942f4254028 Mon Sep 17 00:00:00 2001 From: Trevor Turk Date: Thu, 19 Aug 2010 14:25:15 -0500 Subject: Note about using attr_accessible with nested attributes --- activerecord/lib/active_record/nested_attributes.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb index 520969adbb..e09440d770 100644 --- a/activerecord/lib/active_record/nested_attributes.rb +++ b/activerecord/lib/active_record/nested_attributes.rb @@ -190,6 +190,18 @@ module ActiveRecord # destruction, are saved and destroyed automatically and atomically when # the parent model is saved. This happens inside the transaction initiated # by the parents save method. See ActiveRecord::AutosaveAssociation. + # + # === Using with attr_accessible + # + # The use of attr_accessible can interfere with nested attributes + # if you're not careful. For example, if the Member model above + # was using attr_accessible like this: + # + # attr_accessible :name + # + # You would need to modify it to look like this: + # + # attr_accessible :name, :posts_attributes module ClassMethods REJECT_ALL_BLANK_PROC = proc { |attributes| attributes.all? { |_, value| value.blank? } } -- cgit v1.2.3