Question

I have troubles with wicked_pdf on production server. I have such code here in _results.pdf.haml:

#container

= wicked_pdf_javascript_include_tag "pdf_application"
:javascript
  $(document).ready(function(){drawPDFCharts(#{generate_javascript_for_pdf_generator(@poll.answer_count_per_question)}, "container")});

here is pdf_application.js

//= require jquery
//= require highcharts
//= require poll-pdf-chart-generation.js.coffee

On local machine and staging everithing just fine, but on production there is an error:

Started GET "/121-consumer-electronics.pdf" for 94.76.74.170 at 2013-01-16 13:52:53 +0000
Processing by PollsController#show as PDF
  Parameters: {"id"=>"121-consumer-electronics"}
***************WICKED***************
  Rendered polls/_results.pdf.haml (145.7ms)
Completed 500 Internal Server Error in 816ms

ActionView::Template::Error (pdf_application.js isn't precompiled):
    8: 
    9: #container
    10: 
    11: = wicked_pdf_javascript_include_tag "pdf_application"
    12: :javascript
    13:   $(document).ready(function(){drawPDFCharts(#{generate_javascript_for_pdf_generator(@poll.answer_count_per_question)}, "container")});

Here is my production.rb:

# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = true

# Compress JavaScripts and CSS
config.assets.compress = true

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false

# Generate digests for assets URLs
config.assets.digest = true

I cant figure out how to make it work, I saw some similar questions here, And I tried to add this file to precompile array and restart the server, but it didnt help. As I get I have compiling assets on local machine, and no compiling on production, and somehow this file is not precompiled when I try to run it...

Was it helpful?

Solution

Which file contains the javascript code that you would like to use? Is it poll-pdf-chart-generation.js.coffee?

I am unsure if wicked pdf can use coffee files but someone can please correct me if I am wrong.

I believe a workaround solution is to try converting poll-pdf-chart-generation.js.coffee to a js file and adding it to production.rb:

config.assets.precompile += ['poll-pdf-chart-generation.js']

Reference: Rails guide on asset pipeline

Change your wickedpdf include tag to look at the precompiled js asset:

wicked_pdf_javascript_include_tag "poll-pdf-chart-generation"

And you will also need to precompile your assets:

bundle exec rake assets:precompile

OTHER TIPS

Sounds like the .js file was changed and not recompiled. Rails 3 compiles js, css, and stylesheets into a single file to be sent once to the browser. If anything in the assets directory changes, the whole thing has to be recompiled. Try

bundle exec rake assets:precompile

Good luck

Bob

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top