For conditional validation in Rails, I can do this:
mailed_or_faxed_agenda = Proc.new { |me| me[:agenda_mailed_faxed] }
validates_presence_of :agenda, :if=>!mailed_or_faxed_agenda
but I don’t know how to parameterize the Proc. I would love to use if=>blah(name) but I cannot figure out how to it. Any ideas?
Note: In these ifs one can also use the name of a method, but as a symbol. I can’t imagine how to pass parameters to that.
By “parameterize the Proc”, do you mean currying?
Or just this?
The second problem (sending params to a method), you can do something like this:
Update:
The above can be simplified if you don’t want to parameterize the method that is called. The following is equivalent to passing a literal symbol to
send: