This project is archived and is in readonly mode.
Changeset [e0750d6a5c7f621e4ca12205137c0b135cab444a] by David Dollar
Revision e0750d6a5c7f621e4ca12205137c0b135cab444a,
committed by David Dollar
· July 14th, 2008 @ 02:53 AM
Add :accessible option to Associations for allowing mass assignments using hash. [#474 state:resolved]
Allows nested Hashes (i.e. from nested forms) to hydrate the appropriate
ActiveRecord models.
class Post < ActiveRecord::Base
belongs_to :author, :accessible => true
has_many :comments, :accessible => true
end
post = Post.create({
:title => 'Accessible Attributes',
:author => { :name => 'David Dollar' },
:comments => [
{ :body => 'First Post!' },
{ :body => 'Nested Hashes are great!' }
]
})
post.comments << { :body => 'Another Comment' }
Signed-off-by: Pratik Naik
6 changed files
-
M
activerecord/CHANGELOG -
M
activerecord/lib/active_record/associations.rb -
M
activerecord/lib/active_record/associations/association_collection.rb -
M
activerecord/test/cases/associations_test.rb -
M
activerecord/test/models/author.rb -
M
activerecord/test/models/post.rb