Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 4, Devise and strong parameters #49

Open
AlexVPopov opened this issue Sep 30, 2013 · 0 comments
Open

Rails 4, Devise and strong parameters #49

AlexVPopov opened this issue Sep 30, 2013 · 0 comments

Comments

@AlexVPopov
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant