```ruby
class Vote < ActiveRecord::Base

  belongs_to :idea
  belongs_to :user

  validates :user, uniqueness: {
    scope: :idea,
    message: "A user cannot vote on the same idea twice."
  }
end
```

Add primary keys to Vote model
user
```ruby
class Vote < ActiveRecord::Base

  self.primary_keys = :idea_id, :user_id

  belongs_to :idea
  belongs_to :user

  validates :user, uniqueness: {
    scope: :idea,
    message: "A user cannot vote on the same idea twice."
  }
end
```
assistant