mileszs / wicked_pdf

PDF generator (from HTML) plugin for Ruby on Rails
http://www.mileszs.com/wicked-pdf-plugin
MIT License
3.54k stars 646 forks source link

wicked_pdf_helper trying to use disabled assets pipeline #483

Open mbrehin opened 8 years ago

mbrehin commented 8 years ago

Hi there,

I just encountered a problem while accessing assets with Rails assets disabled.

Here is the related extract of config/application.rb:

config.assets.enabled = false

When using helper methods like wicked_pdf_stylesheet_link_tag, wicked_pdf was still trying to load assets from the assets pipeline.

LoadError (cannot load such file -- sass)

After a short lookup I found the following code which seems to be the source of my problem:

require 'wicked_pdf/wicked_pdf_helper'
require 'wicked_pdf/wicked_pdf_helper/assets'

In wicked_pdf/lib/wicked_pdf/railtie.rb, both helpers are loaded. Unfortunately assets helper methods override the main ones (wicked_pdf_helper). I couldn't find any code that would check the actual assets config.

Is there any configuration/documentation that I missed about it?

bdewater commented 8 years ago

Are you running sprockets 3.0? Try running from master, it's fixed in: https://github.com/mileszs/wicked_pdf/pull/480

Edit: my bad, that's not the same error you're running in to.

mbrehin commented 8 years ago

I've tried with sprockets 3.4 and 3.5, still have the same problem:

LoadError: cannot load such file -- sass

mparramon-kantox commented 7 years ago

Having the same problem here with sprockets 3.7.1, any progress?

gilesdotcodes commented 1 year ago

Hey everyone, (but ultimately @unixmonkey 😂)

I think I'm running into the same/similar issue…and I'm here to share a fix and explore whether this is just a documentation issue?

Working on a rails application with has assets disabled (which is a new experience for me 😱).

Our stylesheets are precompiled locally and kept in public/stylesheets and I couldn't work out why wicked_pdf_stylesheet_link_tag('pdf') wasn't working… …and I'm now fairly certain that wicked_pdf_stylesheet_link_tag appears to be using the method from: /lib/wicked_pdf/wicked_pdf_helper/assets.rb and not /lib/wicked_pdf/wicked_pdf_helper.rb

I've got it working (woohoo 🥳) using: wicked_pdf_stylesheet_link_tag('/stylesheets/pdf')

I'm suppose I'm here to find out why/how it's using the version from assets.rb and whether this is intentional (maybe I've missed something in the documentation?) or whether this is a bug/issue?

Thank you! If it's a documentation issue then potentially I could raise a PR to add something to the README if you like.