Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Devise - logging on with something other than email

Gems / Libraries • Asked by RJ McCollam

I have followed the instructions on this page to allow signing in with something other than the email, but when I try to login I get an error of unidentified method for the new key I am using. In this case student_id. I am able to create an account with the student id and email just fine.

In application_controller.rb I have added the parameters for both sign up and sign in.

  before_action :configure_permitted_parameters, if: :devise_controller?


    def configure_permitted_parameters
        devise_parameter_sanitizer.permit(:sign_up, keys: [:student_id, :email, :password, :password_confirmation])
        devise_parameter_sanitizer.permit(:sign_in, keys: [:student_id, :password])

In the devise initializer I have added the link config.authentication_keys = [:student_id]

Not sure what else I am missing, and don't know enough to read into the error all that well.

Can you post the actual error?

Interesting, so the error was on the ActionDispatch Request object. Can you click the full trace tab and screenshot that too? Assuming your form passes in the student_id, I'd assume that'd be available.

Obvious thing: Did you restart Rails after changing the initializer?

Yes I did restart rails a few times to make sure it wasn't something silly like that.

The full trace can be found here -

I figured. Hmm. This guy overrode the method to include a scope to fix his.

I know I've added a login key to this before without having to do this though.

I had the config.resource_keys uncommented for some reason and once I commented it out all worked as expected.

Thanks for your help here Chris.

Interesting, glad you got it! :D

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 31,575+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.