开发者

How can I skip email validation with Authlogic in Rails?

开发者 https://www.devze.com 2022-12-14 20:04 出处:网络
I use Authlogic for authentication in my Rails project. It provide default validation for email and login field.

I use Authlogic for authentication in my Rails project.

It provide default validation for email and login field.

But, I want to allow email to be null for join because my service is for mo开发者_运维知识库bile and it is difficult to insert email field in mobile device.

How can I skip email validation with Authlogic in Rails?


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


I was digging for this one for awhile - extending on what jaehyun said - say you want to skip email validation in Authlogic on a conditional basis

  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      
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号