pip71
unread,Jan 28, 2009, 3:30:34 AM1/28/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby Reports
Hello All,
Thanks so much for the people who write and maintain Ruport and all
the other surrounding utils, its these tools that truly inspire us and
turn our imagined applications into realities.
As a total newbie to ruby on rails I am struggling to understand a
couple of things with act_as_reportable, this is of course down to my
total lack of ruby knowledge.
But after reading many posts I also have come to the conclusion, like
others that the Ruport book and the payr program are too advanced at
this time for us who are taking our first step into ruby and rails.
For example the code switches between ruby and ruby on rails which
doesn't help when you are trying to learn things from a totally rails
side - I guess i should learn ruby first!
Also I personally feel there is just too much going on in the first
examples, too many tables, too many different ways of doing things,
grouping results, to much new terminology etc.
Another problem is outdated examples on the web where code doesn't
work anymore. for example Ruport::Renderer is now Ruport::Controller.
- The exact same problem with Rails 2 and all the books I bought
talking about Rails 1.
I have managed to get my Ruport in rails working and it does create
pdf's but this is with code similar to the following, with the
database search code inside the Ruport::Controller in my app/reports
folder.
stage :list
def setup
self.data = Mytable.report_table(:all)
end
formatter :pdf do
build :list do
draw_table data
end
But the part I am now having difficulty with is how to transfer my
search results from my applications controllers different search
sections to the ruport controller, I am guessing my @results needs to
be passed and then the data needs to go to an Aggregator, here is my
code below could someone be kind enough to give me some sample code to
make this work?
Customers table has the following columns - name, zip_code,
service_date.
..app/controllers/customers_controller.rb
class CustomersController < ApplicationController
# Search for customers on a selected service date
def customer_zipcode_service
@results = Customers.find ('some fancy search code')
send_data(CustomerReport.render(:pdf, :data => @results,
:filename => "Customer_Report.pdf",
:type => "application/pdf",
:disposition => "inline"))
rescue ActiveRecord::RecordNotFound
flash[:error] = "Report not found."
redirect_to :action => :index
end
...app/reports/Customer_Report.rb
require "templates"
class CustomerReport < Ruport::Controller
stage :list
def setup
data = @results ??? this is where i am stuck ???
end
formatter :pdf do
build :list do
draw_table data
end
end
So as you can see I don't understand how to process the data from my
rails controller.
If anybody could please help with some sample code I would be most
grateful.
Thanks Pip