hi, I''ve a model with validates_*_of statements, but I have no idea how to get the :message back, anyone has a clue? Thanks. -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 9/27/06, Ianne Leson <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > hi, > > I''ve a model with validates_*_of statements, but I have no idea how to > get the :message back, anyone has a clue? Thanks.In your view you need to include the error_messages_for method. This takes a string argument that is the name of an instance variable. in contoller @thing.save #=> fails due to errors in view error_messages_for "thing" You can have as many calls to error_messages_for as you want in one view, for as many instance variables as you have. The docs as www.rubyonrails.org/docs have more in depth explainations. http://api.rubyonrails.org/classes/ActionView/Helpers/ActiveRecordHelper.html#M000460 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Thanks. I also got some other methods from google: the errors are stored in the object @var.errors Daniel ----- wrote:> On 9/27/06, Ianne Leson <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> >> hi, >> >> I''ve a model with validates_*_of statements, but I have no idea how to >> get the :message back, anyone has a clue? Thanks. > > > In your view you need to include the error_messages_for method. This > takes > a string argument that is the name of an instance variable. > > in contoller > @thing.save #=> fails due to errors > > in view > > error_messages_for "thing" > > You can have as many calls to error_messages_for as you want in one > view, > for as many instance variables as you have. > > The docs as www.rubyonrails.org/docs have more in depth explainations. > http://api.rubyonrails.org/classes/ActionView/Helpers/ActiveRecordHelper.html#M000460-- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---