Adding extra registration fields with Devise

It would appear that the code sample in your question is not working because you are not setting the before_filter to call the sanitizer.

before_filter :configure_permitted_parameters, if: :devise_controller?

With that said, it’s probably better to override the controller, as shown in the accepted answer, so that the application controller isn’t doing this check all of the time. The accepted answer can be shortened up with the code below. I’ve tested this code with my application and it works well. All of this is documented in the Strong Parameters section of the README in the 3.0.0.rc tag.

Override the controller:

class RegistrationsController < Devise::RegistrationsController
  before_filter :configure_permitted_parameters, :only => [:create]

  protected

    def configure_permitted_parameters
      devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password) }
    end
end

Then update the routes to use it:

devise_for :members, :controllers => { :registrations => "registrations" }

Leave a Comment