Thursday, March 31, 2011

ROR Model Setup Question: Table Relationships

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?

From stackoverflow
  • class Submission
      has_many :ratings
      validates_uniqueness_of :rating, :scope => :user_id
    end
    

0 comments:

Post a Comment