I have followed the instructions on this page https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-with-something-other-than-their-email-address 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? private 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]) end
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.
That might have been helpful. Here is the 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 - http://www.awesomescreenshot.com/image/2486026/389892e4c6723ca10f0a40718c89bdba
I figured. Hmm. This guy overrode the method to include a scope to fix his. https://github.com/plataformatec/devise/issues/3357
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.
Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.