Prev | Current Page 224 | Next

David Berube

"Practical Reporting with Ruby and Rails"

Since the default name for a foreign key in the meetings table refering
to the user table would be user_id, you manually specify it in your has_many relationship.
Next, you use these models to create an HTML report, which you can use later to
turn your report into a PDF:
CHAPTER 8 n CREATING SALES PERFORMANCE REPORTS WITH SUGARCRM 163
users = User.find(:all,
:conditions=>['not is_admin'],
:order=>'last_name ASC, first_name ASC'
)
html = Erubis::Eruby.new(File.read('rewards_report_template.rhtml')
).evaluate({ :users=>users })
You use an Erubis template to create your report HTML gradually. You create a new
Erubis::Eruby object using the Erubis source from the file rewards_report_template.rhtml,
and then call the evaluate method on it. The evaluate method takes a single argument,
which is a list of variables that are accessible to the Eruby template.
nNote You can use other options to create your HTML. For example, you can use Markaby to create the
output. Markaby uses Ruby methods to represent HTML elements.


Pages:
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
Poker Porady proces leczenia spolszczenia teksty piosenek teksty piosenek