undefined local variable or method `devise_parameter_sanitizer' for

553 views
Skip to first unread message

Prizefighter

unread,
Jul 3, 2013, 1:41:19 PM7/3/13
to plataforma...@googlegroups.com
Hi, I'm trying to use Devise with Rails 4. Following the guide on the wiki, I put the following code in the Applications controller.rb

 before_filter :configure_permitted_parameters, if: :devise_controller?


    protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:name, :email, :family_name, :password, :password_confirmation,  :practice_ids, :practice_ids => []) }
    devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:name, :family_name, :email,  :current_password, :password, :password_confirmation, :practice_ids, :practice_ids => []) }
  end


However it's producing a name error saying that `devise_parameter_sanitizer'  was undefined.  Can anyone help? Thanks

NameError (undefined local variable or method `devise_parameter_sanitizer' for #<Devise::RegistrationsController:0x007fb306078760>):
  app/controllers/application_controller.rb:12:in `configure_permitted_parameters'

Vasiliy Ermolovich

unread,
Jul 3, 2013, 4:39:04 PM7/3/13
to plataforma...@googlegroups.com
Hi,

Are you sure you're using Devise 3.0.0.rc?

Prizefighter wrote:
--

---
You received this message because you are subscribed to the Google
Groups "Devise" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to plataformatec-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Michael Mitchell

unread,
Jul 3, 2013, 4:42:07 PM7/3/13
to plataforma...@googlegroups.com
The wiki says that doing this will work for Rails 3.2 onwards. I assumed that included Rails 4

gem 'devise'

Vasiliy Ermolovich

unread,
Jul 3, 2013, 4:46:38 PM7/3/13
to plataforma...@googlegroups.com
Yeah, 3.0.0.rc should work with Rails 3.2 but method `devise_parameter_sanitizer` was introduced in Devise 3.0.0.rc so you should change your Gemfile entry to this one:

gem 'devise', '3.0.0.rc'

Michael Mitchell wrote:

    For more options, visit https://groups.google.com/groups/opt_out.


    --

    ---
    You received this message because you are subscribed to the Google
    Groups "Devise" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to plataformatec-de...@googlegroups.com

Michael Mitchell

unread,
Jul 3, 2013, 5:27:26 PM7/3/13
to plataforma...@googlegroups.com
thanks
Reply all
Reply to author
Forward
0 new messages