On 1/28/07, oscarpica
<oscarpicasso-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Is there a mean to specify the messages order that are displayed by a
> error_messages_for?
>
> I see that we can specify the objects order. But what about the
> messages related to a same object.
>
> Let say I have an Order.
>
> In my form I have the following order:
> Name
> Address
> Email
> Payment type
>
> and in my model I have:
> validates_presence_of :name, :address, :email, :pay_type
> validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+
> [a-z]{2,})\Z/i
>
> However I get the following order for the error messages:
> * Name can''t be blank
> * Pay type can''t be blank
> * Address can''t be blank
> * Email is invalid
> * Email can''t be blank
>
> Obviously I would like the same order as in the form.
>
> Is it possible with error_messages_for ?
>
>
> >
>
You could use:
<%= error_message_on :order, :name %>
<%= error_message_on :order, :address %>
<%= error_message_on :order, :email %>
...
Hope this helps.
--
Zack Chandler
http://depixelate.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?hl=en
-~----------~----~----~----~------~----~------~--~---