When I create a new game I have this 10.times { @game.rounds.create } for round in @game.rounds 6.times { round.add_actions } end Here are my specifications. A game has and belongs to many teams There are two teams per game. There are three players on a team. Each game can have any number of actions (which belong to a round), but % 6 will always = 0, because they are added in 6s. This does not work: for round in @game.rounds 3.times { @game.teams[0].players << round.actions.create } 3.times { @game.teams[1].players << round.actions.create } end I am trying to get it so each action is linked with a player. Also, so each team is linked to all the actions of each player, so I can track how many times a player has done an action. My problem is I cannot get the actions to link to the player and have the team track how many times an action has been committed, per game. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That was stupid. It''s just 10.times { @game.rounds.create } for round in @game.rounds for player in @game.teams[0].players player.actions << round.actions.create end for player in @game.teams[1].players player.actions << round.actions.create end end On Apr 18, 10:19 am, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> When I create a new game I have this > 10.times { @game.rounds.create } > for round in @game.rounds > 6.times { round.add_actions } > end > > Here are my specifications. > A game has and belongs to many teams > There are two teams per game. > There are three players on a team. > Each game can have any number of actions (which belong to a round), > but % 6 will always = 0, because they are added in 6s. > > This does not work: > for round in @game.rounds > 3.times { @game.teams[0].players << round.actions.create } > 3.times { @game.teams[1].players << round.actions.create } > end > I am trying to get it so each action is linked with a player. Also, so > each team is linked to all the actions of each player, so I can track > how many times a player has done an action. My problem is I cannot get > the actions to link to the player and have the team track how many > times an action has been committed, per game.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Still though, how do I make it so that a team stores how many times each player has committed actions per game? On Apr 18, 10:19 am, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> When I create a new game I have this > 10.times { @game.rounds.create } > for round in @game.rounds > 6.times { round.add_actions } > end > > Here are my specifications. > A game has and belongs to many teams > There are two teams per game. > There are three players on a team. > Each game can have any number of actions (which belong to a round), > but % 6 will always = 0, because they are added in 6s. > > This does not work: > for round in @game.rounds > 3.times { @game.teams[0].players << round.actions.create } > 3.times { @game.teams[1].players << round.actions.create } > end > I am trying to get it so each action is linked with a player. Also, so > each team is linked to all the actions of each player, so I can track > how many times a player has done an action. My problem is I cannot get > the actions to link to the player and have the team track how many > times an action has been committed, per game.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---