Bulk assignment fails when upgrading to Rails 4

deprecated_mass_assignment_security.rb:17:in `attr_accessible': `attr_accessible` is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add `protected_attributes` to your Gemfile to use old one. (RuntimeError) 

I tried what the message says by adding gem 'strong_parameters' to my Gemfile .

But when I do rails s , I get the error above.

Update

I tried:

 config.active_record.whitelist_attributes = true 

in confgi/application.rb , also with false , but I really don't understand this option.

+6
source share
2 answers

In your Gemfile, you will notice that the gem 'protected_attributes' been removed. Remove the hash. Run bundle install .

But since protected_attributes is deprecated and might disappear in the future, use strong_parameters as indicated in the above article.

For more information about strong_parameters, see the link.

+4
source

attr_accessible and attr_protected were ripped from Rails 4 and extracted into protected_attributes . Link this to your application, and then you can use it again.

It is recommended that you use strong_parameters instead of attr_accessible these days, so you will eventually want to switch to this.

+6
source

Source: https://habr.com/ru/post/950491/


All Articles