Forum: Ruby on Rails Order of error_messages_for

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
0895126acbda468cdf7e131445a17b10?d=identicon&s=25 oscarpica (Guest)
on 2007-01-28 22:55
(Received via mailing list)
Is there a mean to specify the messages order that are displayed by a

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:
 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]+\.)+

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 ?
C4dc94c893471878a105761a9207f29b?d=identicon&s=25 Zack Chandler (Guest)
on 2007-01-29 07:59
(Received via mailing list)
On 1/28/07, oscarpica <> wrote:
>  Name
>     * Name can't be blank
> >

You could use:

<%= error_message_on :order, :name %>
<%= error_message_on :order, :address %>
<%= error_message_on :order, :email %>

Hope this helps.

Zack Chandler
This topic is locked and can not be replied to.