Forum: Ruby on Rails validates_presence_of validation order?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
271150968a0474728e0fd04444e1ae87?d=identicon&s=25 Jeff Hagemeier (jhagemeier)
on 2006-03-25 23:04
I have a form with 3 fields: user_id, email and password.
All 3 fields are required, so I have a "validates_presence_of :user_id,
:email, :password" in my model.
Works, but the validation errors show up in a different order than I
specificed in the validates_presence_of statement.

Is there a way to specify the order in which the validations (and
corresponding error messages) should occur using the built in validation
methods like validates_presence_of?

Thanks for the assistance,
Jeff
Ae03102311939454d2b7f1ca3139fd97?d=identicon&s=25 Lindsay Boyd (Guest)
on 2006-03-25 23:42
 > Is there a way to specify the order in which the validations (and
> corresponding error messages) should occur using the built in validation
> methods like validates_presence_of?

Have you tried:

validates_presence_of :user_id

validates_presence_of :email

validates_presence_of :password

Lindsay
271150968a0474728e0fd04444e1ae87?d=identicon&s=25 Jeff Hagemeier (jhagemeier)
on 2006-03-25 23:55
Lindsay Boyd wrote:
> Have you tried:
>
> validates_presence_of :user_id
>
> validates_presence_of :email
>
> validates_presence_of :password
>
> Lindsay

Yes, same results: email can't be blank, followed by user id then
password

Jeff
4005a47a8f2ceee49670b920593c1d52?d=identicon&s=25 Ben Munat (Guest)
on 2006-03-26 04:29
(Received via mailing list)
I think the validation targets are stored in a hash, in which order is
never guaranteed.

Seems like someone was annoyed with this a while back and created a
plugin to control
order of validation... EZ was that you? Hmm, actually I think it was
another
over-achiever... Well, you might search the wiki and/or google for it.

b
This topic is locked and can not be replied to.