mercredi 8 août 2018

How to precompile a pdf asset in Rails?

In Rails 3.2.11 app I'm trying to publish my app to Heroku.

In the assets folder I have a pdf subfolder with some pdf files inside.

In my production.rb file I have added the following:

config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif *.pdf]
config.assets.precompile += ["*.js"]
config.assets.precompile += ["*.css"]
config.assets.precompile += ['pdf/*']
config.assets.precompile += %w( ricerca_wg.pdf  )

If I check the pdf assets paths on my console I get:

 Rails.application.config.assets.paths
=> ["/Users/Augusto/Sites/wisegrowth/app/assets/images",
 "/Users/Augusto/Sites/wisegrowth/app/assets/javascripts",
 "/Users/Augusto/Sites/wisegrowth/app/assets/pdf",
 "/Users/Augusto/Sites/wisegrowth/app/assets/stylesheets",
 "/Users/Augusto/Sites/wisegrowth/vendor/assets/javascripts",
 "/Users/Augusto/Sites/wisegrowth/vendor/assets/stylesheets",
 "/Users/Augusto/.rvm/gems/ruby-1.9.3-p551/gems/jquery-rails-2.3.0/vendor/assets/javascripts",
 "/Users/Augusto/.rvm/gems/ruby-1.9.3-p551/gems/coffee-rails-3.2.2/lib/assets/javascripts",
 "/Users/Augusto/.rvm/gems/ruby-1.9.3-p551/gems/formtastic-2.1.1/app/assets/stylesheets"]

But when I run

rake assets:precompile RAILS_ENV=production

everything is precompiled BUT the pdf files and in my production app on Heroku I get the following error:

ActionView::Template::Error (ricerca_wg.pdf isn't precompiled):

Aucun commentaire:

Enregistrer un commentaire