Re: validation help please

Dave Castellano
Fri, 01 Mar 2013 14:58:53 -0000

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)