Prev | Current Page 345 | Next

David Berube

"Practical Reporting with Ruby and Rails"

If so, you might prefer to require that users maintain separate
lists of trainees and employers and select them from a drop-down list. Although that would be more
awkward, it would reduce the chances of incorrect data input.
CHAPTER 12 n CREATING REPORTS WITH RUBY AND MICROSOFT OFFICE 249
In the log controller, the following code displays your data as XML:
def all
@grades = Grade.find(:all)
render :layout=>false # Only renders as XML...
end
This controller action is pretty simple. It finds all of the grades and renders all the
action without a layout, since it??™s XML and the layout is a builder template. Here??™s the
view itself (Listing 12-6):
xml.instruct! :xml, :version=>"1.0"
xml.instruct! 'xml-stylesheet', :href=>'/stylesheets/log.css'
xml.grades do
@grades.each do |grade|
xml.grade do
xml.student grade.student.name
xml.id grade.id
xml.employer grade.student.employer
xml.class grade.training_class.name
xml.grade grade.percentage_grade
xml.took_class_at grade.took_class_at
end
end
end
This code is an XML builder template, which is the most common way to create XML
output in Rails.


Pages:
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
agencja reklamowa poznań roll-up pieniny noclegi Accept METIN DUSZY