views:

142

answers:

1

I'm developing a site that will have a model for users, a model for submissions, and a model for ratings. Each submission may have only one rating per user. My question is how should I set this up in my models?

+5  A: 
class Submission
  has_many :ratings
  validates_uniqueness_of :rating, :scope => :user_id
end
Ken