Greetings! I have the following model in my code, but I cannot get the conditional validation on multiple columns to work with a custom message.
class Form < Sequel::Model(:requests) one_to_many :comments one_to_one :tour_guide def validate super validates_presence [:tour_guide, :accepted_date] if status == 2, :message => "Tour Guide and Accepted Date must be set in order to approve a request." end end When I attempt to run my application with this validation in place, I receive the following error: /var/www/webapps/tourrequest/classes.rb:14: syntax error, unexpected ',', expecting keyword_end ...:accepted_date] if status == 2, :message => "Tour Guide must... ... ^ (SyntaxError) I would like to use a custom message, but it looks like my syntax is wrong. I have tried the following to no avail: validates_presence([:tour_guide, :accepted_date] if status == 2, :message => "Tour Guide and Accepted Date must be set in order to approve a request.") validates_presence([:tour_guide, :accepted_date] if status == 2), :message => "Tour Guide and Accepted Date must be set in order to approve a request." validates_presence(:tour_guide, :accepted_date if status == 2), :message => "Tour Guide and Accepted Date must be set in order to approve a request." To clarify BOTH these work, just not at the same time: # Multi column validation with message validates_presence [:tour_guide, :accepted_date], :message => "Tour Guide and Accepted Date must be set in order to approve a request." # Multi column validation with conditional, no message validates_presence [:tour_guide, :accepted_date] if status == 2 Thank you for any assistance you can provide! -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
