Module: MassAssignment::ClassMethods
- Defined in:
- lib/mass_assignment.rb
Instance Method Summary collapse
-
#mass_assign(attributes) ⇒ Object
Intializes a new object and assigns the attribute hash to the appropriate attribute writers using the mass_assign method on the newly created object.
Instance Method Details
#mass_assign(attributes) ⇒ Object
Intializes a new object and assigns the attribute hash to the appropriate attribute writers using the mass_assign method on the newly created object.
Example:
User.mass_assign(:username => 'Manfred', :password => 'very secret')
Instead of:
user = User.new
user.mass_assign(:username => 'Manfred', :password => 'very secret')
27 28 29 30 31 |
# File 'lib/mass_assignment.rb', line 27 def mass_assign(attributes) object = new object.mass_assign(attributes) object end |