title: In a Ruby on Rails app, I'm trying to loop through an array within a hash within an array. Why am I getting "syntax error" message?
body: <p>I have a Ruby on Rails application to enter results and create a league table for a football competition.</p>
  <p>I'm trying to input some results by creating records in the database through heroku and I get error messages.</p>
  <p>The application isn't perfectly designed: to enter the results, I have to create the fixtures and enter the score for each team. Then, independently I have to record each goal scorer, creating a record for each goal which is either associated with an existing player or requires me to firstly create a new player and then create the goal.</p>
  <p>When I ran the code below heroku, I got this error:</p>
  <p>syntax error, unexpected ':', expecting keyword_end</p>
  <p>Maybe I'm missing something simple about lopping through an array within a hash?</p>
  <p>Thank you for any advice!</p>
  <pre><code>coalition = Team.find_by(name: &quot;Coalition&quot;)
  moscow_rebels = Team.find_by(name: &quot;Moscow Rebels&quot;)
  red_star = Team.find_by(name: &quot;Red Star&quot;)
  unsanctionables = Team.find_by(name: &quot;The Unsanctionables&quot;)
  cavalry = Team.find_by(name: &quot;Cavalry&quot;)
  galactics = Team.find_by(name: &quot;The Galactics&quot;)
  happy_sundays = Team.find_by(name: &quot;Happy Sundays&quot;)
  hardmen  = Team.find_by(name: &quot;Hardmen&quot;)
  international  = Team.find_by(name: &quot;International&quot;)
  
  evropa = Venue.find_by(name: &quot;Evropa&quot;)
  
  s28 = Season.find_by(number: 28)
  
  start_time = DateTime.new(2020,9,6,11,0,0,'+03:00')
  
  
  scheduled_matches_1 =
  [
  {team_1: cavalry, team_1_goals: 1, team_1_scorers: [&quot;Minaev&quot;], team_2_goals: 6, team_2_scorers: [&quot;Kovalev&quot;, &quot;Kovalev&quot;, &quot;Kovalev&quot;, &quot;Thomas&quot;, &quot;Thomas&quot;, &quot;Grivachev&quot;], team_2: coalition, time: start_time, venue: evropa, season: s28},
  {team_1: hardmen, team_1_goals: 4, team_1_scorers: [&quot;Jones&quot;, &quot;Jones&quot;, &quot;Jones&quot;, &quot;Fusi&quot;], team_2_goals: 2, team_2_scorers: [&quot;Kazamula&quot;, &quot;Ario&quot;], team_2: galactics, time: start_time + 1.hour, venue: evropa, season: s28},
  {team_1: international, team_1_goals: 9, team_1_scorers: [&quot;Kimonnen&quot;, &quot;Kimonnen&quot;, &quot;Kimonnen&quot;, &quot;Burya&quot;, &quot;Burya&quot;, &quot;Zakharyaev&quot;, &quot;Zakharyaev&quot;, &quot;Lavruk&quot;, &quot;Rihter&quot;], team_2_goals: 0, team_2_scorers: [], team_2: happy_sundays, time: start_time+2.hours, venue: evropa, season: s28}
  ]
  
  scheduled_matches.each do |match|
      new_fixture = Fixture.create(time: match[:time], venue: match[:venue], season: match[:season])
      tf1 = TeamFixture.create(team: match[:team_1], fixture: new_fixture)
      tf2 = TeamFixture.create(team: match[:team_2], fixture: new_fixture)
      ts1 = TeamScore.create(team_fixture: tf1, total_goals: match{:team_1_goals})
      ts2 = TeamScore.create(team_fixture: tf2, total_goals: match{:team_2_goals})
      match[:team_1_scorers].each do |scorer|
          if Player.exists?(team: tf1.team, last_name: scorer) 
              Goal.create(team_score: ts1, player: Player.find_by(last_name: scorer))
          else 
              new_player = Player.create(team: tf1.team, last_name: scorer) 
              Goal.create(team_score: ts1, player: new_player)
          end
      end
      match[:team_2_scorers].each do |scorer_2|
          if Player.exists?(team: tf2.team, last_name: scorer_2) 
              Goal.create(team_score: ts2, player: Player.find_by(last_name: scorer_2))
          else 
              new_player = Player.create(team: tf2.team, last_name: scorer_2) 
              Goal.create(team_score: ts2, player: new_player)
          end
      end
  end
  
  </code></pre>