Skip to content

Rails 4, Devise and strong parameters #49

Open
@AlexVPopov

Description

@AlexVPopov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions