Prev | Current Page 99 | Next

David Berube

"Practical Reporting with Ruby and Rails"

Fortunately, this is reasonably easy
to do with FXRuby.
CHAPTER 4 n CREATING REPORTS ON THE DESKTOP 63
Before you can run this example, you??™ll need the database from Chapter 3 (shown
partially in Listing 3-3). You can download the SQL from http://rubyreporting.com/
examples/player_4.sql or from the Source/Downloads area of the Apress web site
(http://.www.apress.com), and then import the data using the command mysql -u
my_mysql_user -p < player_4.sql.
The code to create a simple desktop application for viewing graphs is shown in
Listing 4-3.
Listing 4-3. Desktop Team Performance Grapher (desktop_team_performance_graph.rb)
require 'fox16'
require 'active_record'
require 'optparse'
require 'rubygems'
require 'gruff'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:host => 'localhost',
:username => 'insert_your_mysql_username_here',
:password => 'insert_your_mysql_password_here',
:database => 'players_4')
class Player < ActiveRecord::Base
has_many :plays
end
class Game < ActiveRecord::Base
has_many :plays
end
class Play < ActiveRecord::Base
belongs_to :game
belongs_to :player
end
class Event < ActiveRecord::Base
belongs_to :play
end
include Fox
CHAPTER 4 n CREATING REPORTS ON THE DESKTOP 64
class TransmegtechGraphWindow
def initialize
@main_window=FXMainWindow.


Pages:
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
jak wiązać krawat easy online loans for people with bad credit chemia kosmetyki drukarki fiskalne kraków willa karmazyn międzyzdroje