Frederick Cheung wrote in post #1099720:
> On Friday, March 1, 2013 1:20:24 PM UTC, Ruby-Forum.com User wrote:
>>     if :question_type == "standard"
>>       validates :question,        :presence   => true
>>     ...

> with the :if option
>
> validates :question_type,     :presence  => true
> validates :question,        :presence   => true, :if =>
> :standard_question?
>
> will call the standard_question? method and only enforce the presence
> validation on question if the method returns true. There is also a
> lambda
> form
>
> validates :question,        :presence   => true, :if => lambda {|record|
> record.question_type == 'standard'}
>
> Fred

Thanks Fred,
Got this error
undefined method `standard_question?' for #<Question:0x007f947ddb2e00>
Do I need to write a  standard_question method

(I'm beginner)

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: 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].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to