Hi guys, i have an action called individual user pdf per page, it communicates with two model, the user model which retrives information from the database, but specific information only for all users, it then takes the information and send it to the model report which, then when i inspect the attributes of each user it is displayed in way that i have not called it from the model user, it takes each pair and places it in a different order, so when i write information to a table on a pdf it displays it bad, like initials might be the last record of my table and cellphone might be the first one.. and i have to create a new page for each and every user's information..
my report code look's like:
def self.generate_individual_pdf(people,residents,user,estate = nil, title = nil)
pdf = PDF::Writer.new
title = !title ? "Report" :title
pdf.select_font "Times-Roman"
pdf.text "<em>Compiled By: #{user.presentation_name}</em> <em>Estate: #{estate.name}</em> <em>Created On: #{Time.now.strftime('%d/%m/%Y %H:%M')}</em>", :justification => :center
x = 0
25.times do
pdf.text ""+" "
x+=1
puts x
end
pdf.text "<em>User Report For: #{estate.name}</em> ", :font_size => 18, :bold => true, :justification => :center
if estate.logo
pdf.image "#{RAILS_ROOT}/public"+estate.logo.public_filename,:width => 100, :height => 100, :resize => 1.1, :justification => :center
end
y = 0
#loop people to create table for every person
people.each do |p|
pdf.start_new_page
pdf.text" "+p.Title.to_s+" "+p.Firstname.to_s+" "+p.Lastname.to_s, :font_size => 12, :justification => :center
pdf.text ""+" "
pdf.text ""+" "
pdf.text "Please verify if your details below are correct, and rectify them in the third column of the table.", :font_size => 8
pdf.text ""+" "
table = PDF::SimpleTable.new
table.column_order.push(*["head1","head2","head3"])
headings = ["head1","head2","head3"]
headings.each do |h|
table.columns[h] = PDF::SimpleTable::Column.new(h)
table.columns[h].heading = h.humanize
end
#display tables
table.show_headings = false
table.orientation = :right
table.position = :left
data = []
p.attributes.each_pair do |h|
data << { "head1" => h[0], "head2" => h[1], "head3" => " "}
end
table.data.replace data
table.render_on(pdf)
i = 0
28.times do
pdf.text ""+" "
i+=1
puts i
end
pdf.text "Kind Regards"+ " "+p.Title.to_s+" "+p.Firstname.to_s+" "+p.Lastname.to_s, :font_size => 11
pdf.text ""+" "
pdf.text "Signature "+"......................................."
end
then it produces the output when it loops throught the p.attribute.each_pair do |h| data << {"head1" => h[0], "head2" => h[1], "head3" => " this should be nil "} end
please guys i have been trying to use all this kind of sorting but i just cant get the right answer..anyone who can help please feel free.. thanks in advance.