Saturday, 17 August 2013

Customizing Devise with Strong Parameters

Customizing Devise with Strong Parameters

I'm using Rails 4.0.0 and Devise 3.0.2 and trying to configure Devise with
Strong Parameters following this instruction within the Devise README.
I wrote code like this in the application_controller.rb
class ApplicationController < ActionController::Base
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << :nick
end
end
Then I visited http://localhost:3000/users/sign_up. I got a NoMethodError
in Devise::RegistrationsController#new, which says:
undefined method <<' for {}:ActionController::Parameters
and points to the exact line where I wrote
devise_parameter_sanitizer.for(:sign_up) << :nick
Is there anything I did wrong? Thanks for your help.

No comments:

Post a Comment