aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/nested_attributes.rb
diff options
context:
space:
mode:
authorTrevor Turk <trevorturk@gmail.com>2010-08-19 14:25:15 -0500
committerTrevor Turk <trevorturk@gmail.com>2010-08-19 14:25:15 -0500
commite6b6d3adaddae971a1ba5a1a6bfef942f4254028 (patch)
treeab4720d3d37b996ebb49613d709379ae91300eb8 /activerecord/lib/active_record/nested_attributes.rb
parent0dfb8ff347b3ca72dda24ccb1edc75b46df98668 (diff)
downloadrails-e6b6d3adaddae971a1ba5a1a6bfef942f4254028.tar.gz
rails-e6b6d3adaddae971a1ba5a1a6bfef942f4254028.tar.bz2
rails-e6b6d3adaddae971a1ba5a1a6bfef942f4254028.zip
Note about using attr_accessible with nested attributes
Diffstat (limited to 'activerecord/lib/active_record/nested_attributes.rb')
-rw-r--r--activerecord/lib/active_record/nested_attributes.rb12
1 files changed, 12 insertions, 0 deletions
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 <tt>attr_accessible</tt> can interfere with nested attributes
+ # if you're not careful. For example, if the <tt>Member</tt> model above
+ # was using <tt>attr_accessible</tt> 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? } }