Prev | Current Page 144 | Next

David Berube

"Practical Reporting with Ruby and Rails"

The second route defines URLs that specifically set an output type, like
performance/game_id/player_id.xml and performance/game_id/player_id.html. The next
route specifies that / should map to the Home controller. The remaining routes are catchall
routes. Although they are not used in the current version of this application, it??™s wise to
include them so that you can easily add new controllers.
CHAPTER 5 n CONNECTING YOUR REPORTS TO THE WORLD 100
Let??™s examine the Home controller (Listing 5-11) next:
class HomeController < ApplicationController
def index
@available_players =Player.find(:all)
@available_games = Game.find(:all)
end
end
This code is pretty straightforward. It populates a list of available players and games,
which is passed to your view. Let??™s take a look at that view next.
The first part of the view for the application (Listing 5-17) uses the @available_players
and @available_games variables, and constructs two select boxes, which let users choose a
player and game combination to view:

Team Performance Reporting



<%=select 'player', 'id',
[['Click here to select a player',""]] +
@available_players.


Pages:
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
Patrycja Markowska Mezo Marika Łzy Joseph Malik