I recently upgraded my app from rails 3.2.13 to 4. I have been moving all mass assignment code using attr_accessible in models to strong parameters in controller. Some of the code belongs to model so I cant move them inside a controller hence cant use srong parameters. Is there any way I can deal with mass assignment in models without using protected_attributes gem? Does rails 4 have some specific fallback for these cases without going the old way of attr_accessible?
问问题
238 次
1 回答
0
是的,您可以使用protected_attributes
gem。然而,建议创建服务/表单对象来处理参数,因为模型不应该知道它们。
于 2014-01-01T23:58:21.777 回答