This has been asked partially before and I found the following clip on how to set a class object’s attributes all at once, but it’s not possible with Rails because of mass-assignment protection. (e.g. you can’t Object.attributes={})
Is there a nice way to merge the attributes from one class into another?
object1.attributes = object2.attributes.inject({}){ |h,(k,v)|
h[k]=v if ObjectModel.column_names.include?(k); h
}
Thanks.
Utilize assign_attributes with the
:without_protectionoption.