sam*_*207 1 authentication devise ruby-on-rails-3
我想使用devise进行身份验证,而不是使用电子邮件作为登录,我希望用户使用他们的用户名
为了那个原因
我已将user_name添加到添加到用户模型attr_accessible的users表中:email,:password,:password_confirmation,:remember_me,:user_name
以及'/intilizers/devise.rb'中的config.authentication_keys = [:user_name]
但我的问题是如何跳过电子邮件验证并改为使用user_name
我正在使用rails3和设备1.1.8
提前致谢
干杯
sameera
小智 16
在最近的Devise版本中,你可以添加email_required?您的用户模型的方法.它关闭了可验证模块中的电子邮件验证.
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
def email_required?
false
end
end
Run Code Online (Sandbox Code Playgroud)