On 9 March 2011 02:28, Jim Ruther Nill <[email protected]> wrote:
> On Wed, Mar 9, 2011 at 10:19 AM, Me <[email protected]> wrote:
>>
>> If you have:
>>
>> validates_presence_of
>> validates_uniqueness_of
>> ...
>>
>> validates_each
>>
>>
>> What fires in what order?
>
> the way you order them in your model file. so validates_presence_of goes
> first,
> uniqueness next then validates_each.

Really? I'm not 100% sure that's right - although happy to be corrected.

I've not looked at the source, but I was under the impression the
validations were added to a hash that was iterated when "valid?" is
called, and a hash returns its elements in no guaranteed order...

I tend to do stuff like:

  validates_presence_of :foo
  validates_uniqueness_of :foo, :if => :foo
  validates_length_of :foo, :maximum => 255, :if => :foo

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to