Prev | Current Page 139 | Next

David Berube

"Practical Reporting with Ruby and Rails"

Play Model (app/models/play.rb)
class Play < ActiveRecord::Base
belongs_to :game
belongs_to :player
end
Listing 5-16. Player Model (app/models/player.rb)
class Player < ActiveRecord::Base
has_many :plays
end
CHAPTER 5 n CONNECTING YOUR REPORTS TO THE WORLD 95
Creating the View for the Graphical Report
The final pieces are the views. Place the file shown in Listing 5-17 in app/views/home/
index.html.erb.
Listing 5-17.View for the Team Performance Application (app/views/home/index.html.erb)

Team Performance Reporting



<%=select 'player', 'id',
[['Click here to select a player',""]] +
@available_players.map { |p|
[p.name, p.id] },
{:include_blank=>false} %>
<%=select 'game', 'id',
[['Click here to select a game',""]] +
@available_games.map { |g|
[g.name, g.id] },
{:include_blank=>false} %>