How is attr_accessible used in Rails 4?

前端 未结 5 970
执笔经年
执笔经年 2020-11-22 08:36

attr_accessible seems to no longer work within my model.

What is the way to allow mass assignment in Rails 4?

5条回答
  •  遇见更好的自我
    2020-11-22 09:12

    We can use

    params.require(:person).permit(:name, :age)
    

    where person is Model, you can pass this code on a method person_params & use in place of params[:person] in create method or else method

提交回复
热议问题