How is attr_accessible used in Rails 4?

前端 未结 5 960
执笔经年
执笔经年 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:13

    1) Update Devise so that it can handle Rails 4.0 by adding this line to your application's Gemfile:

    gem 'devise', '3.0.0.rc' 
    

    Then execute:

    $ bundle
    

    2) Add the old functionality of attr_accessible again to rails 4.0

    Try to use attr_accessible and don't comment this out.

    Add this line to your application's Gemfile:

    gem 'protected_attributes'
    

    Then execute:

    $ bundle
    

提交回复
热议问题