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.
devise_parameter_sanitizer.for(:sign_up)returns an empty hash, so it's not possible to call<<method on that. I've submitted [an issue][1], you can follow that. [1]: github.com/plataformatec/devise/issues/2574 - Rafał Cieślak