I followed this guide on How to allow users to log in using my username or email address , and followed all the steps there, but when I try to register through the registrations/new.html.erb
, I get this error:
Email can't be blank
In my model, I have:
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable attr_accessible :username, :email, :password, :password_confirmation, :remember_me attr_accessor :login attr_accessible :login
and
def self.find_first_by_auth_conditions(warden_conditions) conditions = warden_conditions.dup if login = conditions.delete(:login) where(conditions).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first else where(conditions).first end end
Any advice on this issue?
======= UPDATE
I found something here β [rails] How to use Devise and Rails without EMail here is something like:
# Email is not required def email_required? false end
With the addition in my model, I can create an entry with a username and leave the email field blank, but when I try to create a second entry without email, an error occurs in the database:
Mysql2::Error: Duplicate entry '' for key 'index_parents_on_email':...
Should I use this, remove the index from my table in the database and just check the username
in the model? because I really don't need an email field on this model.