我在模型
中对我的电子邮件进行了以下验证:uniqueness => { :scope => :company_id, :message => "Email has already been taken" }
如何为验证唯一性提供两个范围条件
:uniqueness => {:scope => :company_id and :status => 0
,:message => “已经收到电子邮件”}
答案 0 :(得分:0)
试试这个
:uniqueness => { :scope => [:company_id, :status], :message => "Email has already been taken"}, if: Proc.new { |obj| obj.status == 0 }