Ruby on Rails latest stable (v4.0.2) - 1 note - Class: AttributeAssignment
assign_attributes(new_attributes) public

Allows you to set all the attributes by passing in a hash of attributes with keys matching the attribute names (which again matches the column names).

If the passed hash responds to permitted? method and the return value of this method is false an ActiveModel::ForbiddenAttributesError exception is raised.

Show source
Register or log in to add new notes.
September 5, 2012 - (v3.2.1 - v3.2.8)
1 thank


Note that in the example shown in the documentation, `user.assign_attributes({ :name => ‘Josh’, :is_admin => true })` would raise a `ActiveModel::MassAssignmentSecurity::Error` and would not actually update user.name, contrary to what the example seems to demonstrate.