title: Using Group_by Rails
body: <p>Using group_by today, trying to get my head around it and see if its the right solution for what I am trying to achieve. I have the following model</p>
  
  <pre><code>class Fixture &lt; ActiveRecord::Base
    attr_accessible :home_team, :away_team, :kickoff_time, :fixture_date
  end
  </code></pre>
  
  <p>I want to group all the fixtures by fixture_date. So far my controller look like this</p>
  
  <pre><code>def fixturelist
    @fixtures = Fixture.all
    @fixture_date = @fixtures.group_by { |fd| fd.fixture_date }
  end 
  </code></pre>
  
  <p>What i would like to do then in my view is list the home_team and away team matches for that particular date</p>
  
  <p>View</p>
  
  <pre><code>&lt;% @fixture_date.each do |f| %&gt;
   &lt;%= f %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>This outputs an array of all the fixtures by date, so group_by has worked. Im looking for some pointers to get this working correctly, ie see all fixtures listed for each date. seeing a working example should help me understand some more</p>
  
  <p>Example</p>
  
  <pre><code>Date
  
  Team 1 Vs Team2
  Team 1 Vs Team2
  Team 1 Vs Team2
  
  Date 2
  
  Team 1 Vs Team2
  Team 1 Vs Team2
  Team 1 Vs Team2
  </code></pre>
  
  <p>Thanks</p>