Princely Plugin: get nil.size error

Hi All,

I want to generate pdf with css. I am using princely plugin.

This is code which I written

def pdf    prince = Prince.new()    html_string = render_to_string(:template => '/users/paid_invoice.pdf.erb')    send_data(      prince.pdf_from_string(html_string),      :filename => 'some_document.pdf',      :type => 'application/pdf'    ) end

But I am getting error of nil.size

You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.size

RAILS_ROOT: /var/www/sortapp Application Trace | Framework Trace | Full Trace

/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/streaming.rb:123:in `send_data' app/controllers/users_controller.rb:135:in `pdf'

I also used make_and_send_pdf function but got the same error. I thought I am getting error in render_to_string function.

Can anyone tell me how can I solve this issues?

Thanks in advance

Did you ever figure out this problem?

I have a working application and my code works on my laptop, but when I try it on our production server I come up with this error, but for the life of me I can't figure out why it is being thrown on one machine and not the other.

NoMethodError: undefined method `size' for nil:NilClass

[GEM_ROOT]/gems/actionpack-2.1.0/lib/action_controller/streaming.rb:123:in `send_data' [RAILS_ROOT]/vendor/plugins/princely/lib/pdf_helper.rb:45:in `make_and_send_pdf' [RAILS_ROOT]/vendor/plugins/princely/lib/pdf_helper.rb:13:in `render' [RAILS_ROOT]/app/controllers/driver_payments_controller.rb:13:in `print'

Anyone got any ideas?

Thanks.

Brijesh Shah wrote:

This unfortunatly wasn't the problem, but I did manage to figure out I only got it when running through mod_rails. We just deployed the app to another server that was rebuilt from scratch and it is working now, so no idea what the actual cause was.

Thanks for the help.