我是初次使用rails并处理具有以下情况的应用程序:
用户有技能(例如漂流,跳舞) 用户参加竞赛 比赛测量多种技能 在每场比赛结束时,每位用户都会获得一个分数(例如:舞蹈:5,漂流:4)
这是建模的最好方法吗?
谢谢,
答案 0 :(得分:1)
这很讨厌:最后我真的不确定这是不是正确的方式
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
end