rails3-devise-rspec-cucumber icon indicating copy to clipboard operation
rails3-devise-rspec-cucumber copied to clipboard

Rails 4, Devise and strong parameters

Open AlexVPopov opened this issue 11 years ago • 0 comments

If you are using Rails 4 you'll stumble on a problem in the section "Modify the User Model". Adding the line attr_accessible :name, :email, :password, :password_confirmation, :remember_me will cause:

`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) 

To know why, read this. In short, to correct the problem, delete this line from app/models/user.rb and add this code to app/controllers/application_controller.rb:

before_filter :configure_permitted_parameters, if: :devise_controller?

protected

def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << :name
end

More info about this here.

AlexVPopov avatar Sep 30 '13 09:09 AlexVPopov