I'm using devise for user authentication. However, when a user tries to create an account I am getting this error:
NameError (undefined local variable or method `devise_parameter_sanitizer'
This is what my devise registrations controller looks like:
def sign_up_params
devise_parameter_sanitizer.for(:sign_up)
end
Any ideas?
Thanks in advance
try to use rails4 branch
gem 'devise', github: 'plataformatec/devise', branch: 'rails4'
Looking at the devise open issues on Github i found this: https://github.com/plataformatec/devise/issues/2372 - seem to do the trick for me. note that this is probably a rails 4 issue.
For anyone who ends up here with error
undefined method `<<' for {}:ActionController::Parameters
you need to upgrade to Devise 3.1.0.rc as in this comment
which basically means using master branch version
gem 'devise', git: 'git://github.com/plataformatec/devise.git'
hope I help some lost souls as I was for last half an hour.
The latest released Gem for Devise at the time of writing is 2.2.4. This does not include the devise_parameter_sanitizer
method, hence the error you are seeing.
You are probably following the manual for Devise at https://github.com/plataformatec/devise. The section on Rails 4 and Strong Parameters has been added recently.
You have a few options:
Get the latest master version of Devise using bundler, so that the devise_parameter_sanitizer
method is available:
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'
Don't apply ActiveModel::ForbiddenAttributesProtection
to your User model, so strong parameters are not even used. More info here: Devise and Strong Parameters
Override the required Devise controllers directly. See here: https://gist.github.com/kazpsp/3350730