I am implementing Omniauth- Identity and I have seen the Railcast by Ryan Bates on doing it. When he is going through the login view he off-handedly mentions that the login field defaults to e-mail but that it can be customized. When I try to sign in with a username that is stored in my identity table under “login” column I just get a MySql error
Unknown column 'identities.email
This is expected since as stated above Identity defaults to this auth_key. In the source code for the gem there is this definition
def auth_key(method = false)
@auth_key = method.to_s unless method == false
@auth_key = nil if @auth_key == ''
@auth_key || 'email'
end
So I assume that somewhere I am supposed to be able to call auth_key(login) and it would query the right column in my database. My question is where. I tried overwriting the method in my model replacing ’email’ with ‘login’ but it didn’t do anything.
I am calling the /auth/identity/callback from my sessions/new view just like Ryan Bates does. Thank you very much and sorry if it is obvious but it seems that all I could find on the internet were regurgitations of the Railscasts tutorial.
Originally I was trying to override the gem code by redefining auth_key… I was positive that I had tried just writing
in my identity.rb but I guess I didn’t since doing that right after I posted the question worked out. Either way I hope it helps other people.