Prev | Current Page 201 | Next

David Berube

"Practical Reporting with Ruby and Rails"

In other words, the following two lines are
identical:
some_object.some_method(some_value)
some.object.send('some_method', some_value)
By using the send method, you can loop through the array and set the appropriate
value for each field; otherwise, you would need to hard-code which methods to use,
which would be much longer and also defeat the purpose of dynamically generating a
schema.
Finally, the save method of the new PaypalTransaction object is called. It saves your
object into the database.
Analyzing the Data
Once the data has been entered into the database, you need a way to analyze it. In this
case, you are going to use an HTML graph of the various weeks, which will show the
weekend vs. weekday spending. The weekend spending will be colored red, and the
weekday spending will be shown in green. The code in Listing 7-2 does just that, using
Markaby.
CHAPTER 7 n TRACKING EXPENDITURES WITH PAYPAL 144
Listing 7-2. Using Markaby to Create an Expense Report (paypal_expense_report.rb)
require 'active_record'
require 'fastercsv'
require 'yaml'
require 'markaby'
(puts "usage: #{$0} mysql_hostname mysql_username " <<
"mysql_password database_name"; exit) unless ARGV.


Pages:
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
SPA internet torby reklamowe zaproszenia slubne utylizacja komputerów