Hello
I have a user table in my db.
A user has a status field, status is an INT an can be between 1-5.
When a new user sign up I want to use “validates_uniqueness_of :login”
in user model.
But I don’t want to validate the new user against users with status ==
5.
Can I do this with some :if or :conditions?
(I prefer not to use my own validate method)
On Nov 8, 2007 7:37 AM, Daniel Hansson
[email protected] wrote:
Can I do this with some :if or :conditions?
(I prefer not to use my own validate method)
I don’t think it can be done. I see two options:
- Write your own validate method
- Create another column in the table that would have the a single
value for all rows with status 1-4 and use that in the :scope option
of validates_uniqueness_of. You could manage this column automatically
via before_save.