On Nov 8, 2007 7:37 AM, Daniel Hansson
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> 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)
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.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---