Reputation: 8998
In a model I have the following validations:
validates_presence_of :company_name, :message => "Must have a company name"
validates_uniqueness_of :company_name, :message => "Does this company exist? As this company name isn't unique."
Does this mean that it will check for the presence of the company name before its uniqueness?
Upvotes: 2
Views: 271
Reputation: 1156
Yes, the check will be done sequentially
You can check it with:
if obj.errors.on(:company_name)
errMsg << obj.errors.on(:company_name)[0]
end
Upvotes: 2
Reputation: 257
From the rails guide: "validations will be run in the same order as they were registered."
Upvotes: 3