[Rails] I need "validates_presence_of" help

Sébastien Gruhier seb at itseb.com
Fri Aug 11 07:34:29 GMT 2006


something like this should work

validates_presence_of Field1, Field2 :if => Proc.new {|model|   
model.Field3.nil? }
validates_presence_of Field3 :if => Proc.new {|model|  model.  
Field1.nil? and model.Field2.nil? }

Seb
Le 10 août 06 à 21:37, Ras Ras a écrit :

> Hi - I have 3 fileds a user can fill out. They can fill out 2 of  
> them or
> just one of them, for example.
>
> fill out these 2 fields:
> Field1 and Field2
>
> Or fill out this field:
> Field3
>
> In my model how do I use validates_presence_of for Field1 and  
> Field2 or
> just Field3.
>
> I want to do something like this:
> validates_presence_of Field1, Field2
> OR
> validates_presence_of  Field3
>
> So the user can fill out Field1, Field2 and be a succesful update or
> just fill out Field3 and be a succesful update.  Any help will be
> apreciated, thank you.
>
> -- 
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060811/9973cbd9/attachment.html


More information about the Rails mailing list