Ruby on Rails Friday, March 1, 2013

Dave,  you have to add an instance method "standard_question?" to your model

def standard_question?
end

from the url below you can see that you can pass a :message param to customize the error message

http://guides.rubyonrails.org/active_record_validations_callbacks.html#message


On Fri, Mar 1, 2013 at 11:13 AM, Dave Castellano <lists@ruby-forum.com> wrote:
Thanks again,

Is there a way to add a message if validation fails using lambda method
(I am using Lambda method until I can figure out why
validates :question,        :presence   => true, :if
=>:standard_question?
generates
undefined method `standard_question?' for #<Question:0x007f947ddb2e00>)

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment