This project is archived and is in readonly mode.

Changeset [e0750d6a5c7f621e4ca12205137c0b135cab444a] 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

http://github.com/rails/rails/co...

Committed by David Dollar

  • 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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>