2009-12-22 75 views
4

我在我的Rails項目中使用Authlogic進行身份驗證。如何使用Rails中的Authlogic跳過電子郵件驗證?

它爲電子郵件和登錄字段提供默認驗證。

但是,我想允許電子郵件爲空,因爲我的服務是針對移動的,並且很難在移動設備中插入電子郵件字段。

如何在Rails中使用Authlogic跳過電子郵件驗證?

回答

7
class User < ActiveRecord::Base 
    acts_as_authentic do |c| 
    c.validate_email_field = false 
    end 
end 
2

我挖這個一段時間 - 說什麼jaehyun擴展 - 說你要跳過Authlogic電子郵件驗證條件的基礎上

acts_as_authentic do |c| 
    c.merge_validates_length_of_email_field_options({:unless => Proc.new { |user| user.has_no_email? }}) 
    c.merge_validates_format_of_email_field_options({:unless => Proc.new { |user| user.has_no_email? }}) 
    end