One way I figured is this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
We have an
AssetsMaster module that includes the
Sprockets::Helpers::RailsHelper. This helper contains all path / url methods and some other asset-related goodness. Including this file would be sufficient in Rails 3.0, but it’s not in Rails 3.1+. In the latest version we need to have three more methods:
relative_url_root. The first one should refer to the app configuration, and the other two can be
You may have noticed how I adjust the assets configuration in my Rake task (lines 4-6). As you can see, I disable debugging and enable digests explicitly to break the ties from the environment config.
After all this magic, you can finally enjoy your desired
image_path helper that will obey Asset Pipeline configuration to the letter.