Rails Nested Attributes Mass Assignment Error

a 夏天 提交于 2019-12-25 03:34:49

问题


I have a user model where I cannot create a client due to it being unwritable in mass assignment.

How do I make it so that I can create a client model?

Code and error are found here: http://pastie.org/1206482


回答1:


I think you have to add:

attr_accessible :client_attributes

to your user model. client_attributes is the hash in the user hash posted to the create action.

The transmitted hash looks something like this: :user => { :username => "one", ..., :client_attributes => { :name => "client" } }



来源:https://stackoverflow.com/questions/3886365/rails-nested-attributes-mass-assignment-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!