Can anyone explain the strict mass assignment in Rails 3.2?

I am only speeding up with Rails 3.2 and when I use create or update_attributes I always get mass assignment errors. This is normal? How do I create and update records?

+3


source to share


1 answer


add the attributes you want to set with massassignment to whitelist in the model attr_accessible :my_attribute

allowing to set related nested attributes of a model through the same form, you must set accepts_nested_attributes_for

for this model and add attributes to the whitelistattr_accessible :$RELATED_MODEL_attributes



read these links. http://api.rubyonrails.org/classes/ActiveModel/MassAssignmentSecurity/ClassMethods.html

http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html

+5


source







All Articles