Trent
Trent

Reputation: 126

Using Username or Email for Devise Causing Error

I followed the wiki post to add username as another authentication method for Devise.. https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign_in-using-their-username-or-email-address

Once I completed the steps and tried to sign in I was given this error:

ActiveRecord::StatementInvalid in Devise::SessionsController#create 
SQLite3::SQLException: no such column: users.login: SELECT  "users".* FROM "users"  WHERE "users"."login" = '[email protected]' LIMIT 1

As you can see, the create method is looking for a login column. I am not sure why this is happening. I overrode the registrations controller and added the self.find_for_authentication method to it along with the other methods.

Any thoughts?

What code would I need to post to give some more clues?

Upvotes: 1

Views: 1088

Answers (1)

José Valim
José Valim

Reputation: 51339

You probably missed some detail when copying the code. Are you sure you have defined def self.find_for_authentication, i.e. a class method? To be double sure, try adding a raise inside your method definition and see if the error will appear.

Upvotes: 2

Related Questions