3

Everything works great in Development. And app deploys as normal with Capistrano. Assets (javascript & css) appear to be fully pre-compiled and each, along with images, are given a "fingerprint". Problem is when using image_tag("image-name.png") in my view the html it creates in production doesn't include the 'fingerprint'.

The rendered HTML we get in production:

<img alt="Image-name" src="/assets/image-name.png" />

instead of, what I would expect, should be:

<img alt="Image-name" src="/assets/image-name-b89cae2830c2901f844c353b3f3942fe.png" />

So which of Rails 3.1's myriad config options did we botch?

Edit

The troublesome images appear to be those included in a 3rd-party Colorbox image viewing tool we use. Rails 3.1 is fingerprinting its assets (border.png, etc.) but, clearly, the source code for this javascript library doesn't use helpers like image_tag. So in production it is still looking for images named /assets/colorbox/border.png. Currently images are in /vendor/assets/images and work fine in Development. Is there a way to prevent just these images from being "fingerprinted"?

Meltemi
  • 37,979
  • 50
  • 195
  • 293
  • Might want to check out this question, http://stackoverflow.com/questions/7336265/problem-with-missing-fingerprints-in-asset-pathes – basicxman Sep 14 '11 at 01:20
  • According to the [Rails Guides](http://guides.rubyonrails.org/asset_pipeline.html#in-production): "The fingerprinting behavior is controlled by the setting of config.assets.digest setting in Rails (which is true for production, false for everything else)." So, `config.assets.digest` should be assumed *true* in production and *false* everywhere else. Or am I reading this wrong?!? – Meltemi Sep 14 '11 at 02:10
  • 1
    adding `config.assets.digest = true` to `production.rb` appears to be only *partially* helpful. It got some images (mine) working. But there are some included in the 3rd-party javascript tool (see edit in main post) that we use that are still 'broken'. – Meltemi Sep 14 '11 at 04:18
  • I am having the same problem. My images on production are not pointed to the fingerprinted versions. – Min Ming Lo Feb 16 '12 at 06:17

1 Answers1

1

Well, here's how I hacked the 3rd-party files to make things work:

The offending images were in files like vendor/assets/stylesheets/colorbox.css. I first changed the extension of the files to .scss then I changed each url(colorbox/image.png) to image_url("color box/image.png") and now everything is peachy. Assets are served normally in development and fingerprinted in production.

Still like to see the "proper" way to add 3rd-party (vendor) javascript libraries & css to a Rails 3.1 app. Rails team must have anticipate a drop-in solution that doesn't require editing?!? So, please, feel free to offer up other solutions.


Aside: where I previously had manually configured my Capistrano recipe with:

run "cd #{release_path}; RAILS_ENV=production bundle exec rake assets:precompile"

…and its accompanying after deploy:update_code …. I have now removed those lines and instead added load 'deploy/assets to my Capfile. I don't think this makes any difference in the above problem but I wanted to document it anyway as adding your own recipe for pipeline precompiling is no longer necessary in Capistrano 2.8 as it was in the 3.1rc days.

Meltemi
  • 37,979
  • 50
  • 195
  • 293
  • 1
    I am having the EXACT same problem, I am surprised by how few questions or blog posts there are so far regarding this problem. I voiced the exact concern on Railscasts.com's comment section for the Upgradeing to Rails 3.1 episode, saying similar to what you said: how come Rails team didn't anticipate 3rd party libraries that have images? We cannot possibly dive into changing url() for each css files we come across. That looks real bad. – Nik So Sep 16 '11 at 07:07