> I am wondering of how to use validates_presence_of in case I want to
> check either one of the field is present
>
> for example
> validates_presence_of :phone_number, mobile_number
>
> I want to check if either one presents, it accepts the request. How
> can we do that
One way...
validates_presence_of :phone_number, :if => Proc.new { |thing|
thing.mobile_number.blank? }
validates_presence_of :mobile_number, :if => Proc.new { |thing|
thing.phone_number.blank? }
Probably others as well.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---