我是rails的新手,正在开发一个有以下情况的应用程序:
用户有技能(例如漂流,跳舞)用户参与竞赛竞赛测量多项技能在每次竞赛结束时,每个用户都会得到一个分数(例如跳舞: 5,漂流: 4)
对此建模的最佳方式是什么?
谢谢,
发布于 2012-04-28 09:55:54
事情变得很糟糕:最后我实际上不确定这是不是正确的方式
class Skill < ActiveRecord::Base
has_many :skill_scores
has_many :user_skills
end
class UserSkill < ActiveRecord::Base
belongs_to :user
belongs_to :skill
end
class SkillScore < ActiveRecord::Base
belongs_to :user
belongs_to :contest
belongs_to :skill
end
class User < ActiveRecord::Base
has_many :skills
has_many :contests, :through => :contest_participations
has_many :skill_scores
end
class Contest < ActiveRecord::Base
has_many :users, :through => :contest_participations
has_many :skill_scores
end
class ContestParticipation < ActiveRecord::Base
belongs_to :user
belongs_to :contest
endhttps://stackoverflow.com/questions/10359767
复制相似问题