Reputation: 27114
I have a user model that has_one signup.
I'm having a recurring bug where users will click multiple times and create many unnecessary signups. How can I validate the user only gets one? Is there a way to do that from the model?
Upvotes: 0
Views: 430
Reputation: 6168
In rails 3 you could do like this.
validates :field, :uniqueness => true
If you want your custom message then
validates :field, :uniqueness => {:message => 'your message'}
Upvotes: 1
Reputation: 836
Not sure about your model, but validates_uniqueness_of might be what you are looking for.
Upvotes: 4