I'm building a system for registrering table soccer matches. I have
however run into this problem:
Each time a match is registered, a match is created in a match table. A
match has_many participants, and the MatchParticipant table contains
these informations: user_id, match_id, side (a or b), score and winner
(true/false). It's the latter I'm having trouble with. So a match might
have for instance 2 matchparticipants associated with it.
So, I wan't to iterate over the data that the user sends from a form to
decide which participant is the winner. Basically it's just comparing
the score of participant #1 to the score of participant #2 and then
return true or false to be writtin in the Matchparticipant winner
column. But how do I do this?
The parameters sent from the user could look like this:
So I just want to add for instance: "winner" => "true"/"false", to each
participant when I build the row, depending on whether they are the
winner or not.
If you need more information I'll be happy to provide it to you.