I followed this article to implement user registration either with email or username. https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address
User.rb
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, authentication_keys: [:login]
attr_accessor :login
def login=(login)
@login = login
end
def login
@login || self.contact_no || self.email
end
def self.find_for_database_authentication(warden_conditions)
conditions = warden_conditions.dup
if login = conditions.delete(:login)
where(conditions.to_hash).where(["lower(contact_no) = :value OR lower(email) = :value", { :value => login.downcase }]).first
elsif conditions.has_key?(:contact_no) || conditions.has_key?(:email)
where(conditions.to_hash).first
end
end
Devise.rb
config.authentication_keys = [ :login ]
But still getting error 'email can't be blank'. How can I fix this? Where am I getting wrong?