I'm fairly new to Rails so I'm having some trouble with what is probably an easy task. Any assistance would be appreciated.
I have two fields, I only have to have one of them filled in...
At the moment I'm working on some variation of
validates_presence_of :foo, :if => "bar.empty?"
Verbatim, that will of course not work..
Suggestions?
Tom, :if takes a 'block'
validates_presence_of :foo, :if => Proc.new { | your_model_instance
your_model_instance.bar.empty? }
as you can see, the block is passed the current instance, which you can examine - returning tru means the validation will take place.
cheers, Jodi