# Validates\_uniqueness\_of question

**URL:** <https://www.ruby-forum.com/t/validates-uniqueness-of-question/120589>\
**Category:** Rails\
**Created:** [November 18, 2007, 10:47pm UTC](https://www.ruby-forum.com/t/validates-uniqueness-of-question/120589 "2007-11-18T22:47:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jables](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@Jables](https://www.ruby-forum.com/u/Jables)\
**Post date:** [November 18, 2007, 10:47pm UTC](https://www.ruby-forum.com/t/validates-uniqueness-of-question/120589/1 "2007-11-18T22:47:37Z")

</div>

Given three models: a design model, a votes model, and a users model  
the problem is a user can only vote for a design once.

If I do a validates\_uniqueness\_of :user in the votes model that means  
a user can only vote once, period. What I want is to say a user can  
only vote for a single design once. Anyone know the best way to do  
this? Thanks.

JB

---

<div class="post-metadata">

**Author:** ![Jables](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@Jables](https://www.ruby-forum.com/u/Jables)\
**Post date:** [November 18, 2007, 11:59pm UTC](https://www.ruby-forum.com/t/validates-uniqueness-of-question/120589/2 "2007-11-18T23:59:05Z")

</div>

JB, I think you would need to use a scope, for example:

validates\_uniqueness\_of :user\_id, :scope =\> :design\_id
