Story 4 – Show home games and away games on a team page

Let’s create the team show page. We want to show all upcomming games and all away games.

Task 1: Create show page for team

Lets code up the html for the page heading and the Away Games and Home Games section. Ignore the other html sections for now.

Task 2: Let’s write a test before we create the associations

This test will fail at first, we’ll need to implement task 3 before the unit test will run. Add this unit test to the team_test.rb file:

Task 3: Create has_many associations for away_games and home_games on the team model

To implement the view and make the test pass we’ll need to create the right associations. Let’s read up on the has_many association and the options, read the following sections:

  • 4.3 has_many Association Reference
  • 4.3.1 Methods Added
  • 4.3.2 Options for has_many

Let’s finish the story now by implementing the associations for away_games and home_games.

No comments yet

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS