开发者

Validations on models for a sports league

开发者 https://www.devze.com 2023-04-03 13:30 出处:网络
The schema question has been asked before and the below is a snapshot of what I believe is right. The issue I\'m having now is getting a validation to work so 开发者_JS百科that the same two players do

The schema question has been asked before and the below is a snapshot of what I believe is right. The issue I'm having now is getting a validation to work so 开发者_JS百科that the same two players don't play more than once in a division. For starters we have three different inserts happening:

  • Create match
  • Create result_1 (whoever submitted)
  • Create result_2

So the results can come in any order (dependent on who submitted) and aren't in the same record which would have made looking for a duplicate easier.

Match
- division_id


Result
- match_id
- player_id
- score

Is the only way around this to write a separate validation by taking the player_id's and comparing them in the database?


If the data you're validating against lives in the database, then you need to go to the database, yes.

0

精彩评论

暂无评论...
验证码 换一张
取 消