Search code examples
ruby-on-railsnomethoderror

NoMethodError in Users::RegistrationsController#new in Rails


I messed something up, and I dont know where. When I run my rails server, it gives me : NoMethodError in Users::RegistrationsController#new , and : undefined method `configure_permitted_parameters' for # The error message says the code error is :

        case filter
    when Symbol
      lambda { |target, _, &blk| target.send filter, &blk }
    when String
      l = eval "lambda { |value| #{filter} }"
      lambda { |target, value| target.instance_exec(value, &l) }

starting on line 430, error on 432 (line 3 in this). I cant find the file this is in.


Solution

  • I'm assuming you're on rails 4 ?

    Try adding

    before_action :configure_permitted_parameters, if: :devise_controller?
    
    protected
    
    def configure_permitted_parameters
      # Replace the keys to fit your needs
      devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
    end
    

    To your application_controller.rb

    Please also read the following:

    This will help you https://github.com/plataformatec/devise#strong-parameters