PDF Writer must be marshal-able for simple table to work
Sunday, March 23rd, 2008This one had me stumped for a while, I was getting errors like
can't dump File
C:/dev/ruby/current/lib/ruby/gems/1.8/gems/transaction-simple-1.4.0/lib/transaction/simple.rb:132:in `dump'
C:/dev/ruby/current/lib/ruby/gems/1.8/gems/transaction-simple-1.4.0/lib/transaction/simple.rb:132:in `start_transaction'
etc.
Which were thrown when rendering a table in PDF Writer. It turns out that the whole pdfwriter object needs to marshal-able and mine wasn’t. I had inherited pdf writer and added a logging function to help debug some other issues
def logger
@logger ||= Logger.new "#{RAILS_ROOT}/log/debug.log"
end
@logger was now storing a reference to a file which wasn’t marshal-able so it broke the siple table render_on getting rid of the class object (@logger ||= ) fixed the problem even though it made the logging less efficient.