我試圖找出這裏最好的路徑,以前的問題並沒有說明問題,但這可能是由於我的解釋,所以即將嘗試並打破它分解成小塊,希望能夠聚集在問題的一些更多的瞭解,同時在bitesized塊學習應用設置正確的模型關聯Rails 3
其中一個用戶在即將到來的比賽的比分predition一個足球預測應用的
範圍。根據他們是否預測正確,他們將被分配一些積分。每個用戶可以創建一個團隊,然後成爲聯盟的一部分。
現有型號
class User
has_many predictions #prediction model has user_id as FK
has_many :teams #team model has user_id as FK
attr_accessible :prediction_id
end
class Team
belongs_to :user
attr_accessible :team_name, :user_id, :key
end
class Prediction
has_many fixtures #to allow predictions from multiple users<br>
attr_accessible :home_team, :away_team, :home_score, :away_score, :fixture_date, :fixture_id, :user_id
end
class Result
attr_accessible :home_team, :away_team, :fixture_date, :home_score, :away_score
end
我的問題是應該有一個單獨的模型,如點存儲從用戶獲得預測的點?因此,例如,如果用戶正確預測分數,他們將得到3分。
在Point
模型我將不得不屬性
result_id, prediction_id, allocated_points
所以在這裏我可以比較反對的結果預測和分配點..
理解,因爲確實難倒就這一個
任何意見
嗨,感謝您的回答,我已經更新了我的關聯和屬性,如果您不介意再次看看 – Richlewis 2013-05-12 14:43:14
我不確定什麼是燈具,您似乎表示預測可以有很多用戶嗎?如果預測不屬於一個用戶? – Kris 2013-05-19 20:02:16