Why slicing the params hash poses a security issue on mass-assignment?

前端 未结 5 1044
余生分开走
余生分开走 2021-02-13 03:25

The official way of preventing security risks with mass-assignment is using attr_accessible. However, some programmers feel this is not a job for the model (or at least not

5条回答
  •  余生分开走
    2021-02-13 04:00

    The problem with slice and except in controller might occur in combination with accept_nested_attributes_for in your model. If you use nested attributes, you would need to slice parameters on all places, where you update them in controller, which isn't always the easiest task, especially with deeply nested scenarios. With using attr_accesible you don't have this problem.

提交回复
热议问题