Pdf simpletable help needed

i am trying to generate a pdf of all of the users in an application that
i have built. i am still pretty new to ruby and rails so i don’t know
the best way to go about it.

here is my controller code:

require ‘pdf/writer’
require ‘pdf/simpletable’

class ReportsController < ApplicationController

def test
_pdf = PDF::Writer.new
table = PDF::SimpleTable.new
user_data = []
for user in User.find(:all)
user_data << user.attributes
end
table.data = user_data
table.render_on(_pdf)

send_data _pdf.render, :filename => 'hello.pdf', :type => 

‘application/pdf’
end
end

i couldn’t figure out a better way to get the data out of the user model
than looping through and adding the attributes to an empty array. then i
used the array as my data for creating the pdf table.

currently i am getting an error saying that my columns are not defined,
yet using the console, i can see that my array is formatted just like
the ones in the examples.

any help would be greatly appreciated.
Thanks

On 6/19/06, Josh K. [email protected] wrote:

def test
_pdf = PDF::Writer.new
table = PDF::SimpleTable.new
user_data = []
for user in User.find(:all)
user_data << user.attributes
end

You need to define your columns and column order here. You’re missing
something. Your array may be complete, but your table definition
isn’t.

table.data = user_data
table.render_on(_pdf)

After you define your columns, the above will work.

-austin

Austin Z. * [email protected] * http://www.halostatue.ca/
* [email protected] * You are in a maze of twisty little passages, all alike. // halo • statue
* [email protected]