Prev | Current Page 221 | Next

David Berube

"Practical Reporting with Ruby and Rails"

(Since you??™re using the sample
data, which is randomly generated by SugarCRM when you install it, your exact results
will vary.)
Figure 8-1. PDF salesperson rewards report
CHAPTER 8 n CREATING SALES PERFORMANCE REPORTS WITH SUGARCRM 161
Now, let??™s take a look at this example line by line.
Dissecting the Code
For the report (Listing 8-2), first you create a connection to the database, as follows:
ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:host => 'localhost',
:username => 'someuser',
:password => 'password',
:database => 'sugarcrm')
This sets a base connection used by Active Record for all models by default, as discussed
in Chapter 1 and used in previous examples. Of course, you??™ll need to replace the
italicized values with appropriate values for your system. That??™s also true of the code??™s
next section, which specifies the path to your helper utilities:
path_to_ps2pdf = '/some/path/to/ps2pdf' #Insert your path to ps2pdf here.
#Note that ps2pdf should be included
#with your Ghostscript distribution.


Pages:
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
Freddie Mercury Moby Scott McKenzie Emmanuel Moire Giorgio Moroder