On Friday, April 3, 2015 at 2:23:28 PM UTC-7, Elanor Riley wrote: > > 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. >
You were close: validates_presence [:tour_guide, :accepted_date], :message => "Tour Guide and Accepted Date must be set in order to approve a request." if status == 2 Thanks, Jeremy -- 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.
