Sergio A. Sergio A. - 6 months ago 28
Ruby Question

Rails 4 - How to access to gem precompiled assets

I have an application an I'm precompiling the assets to deploy to Heroku. I'm using a gem which uses some internal images. I run.

RAILS_ENV=production bundle exec rake assets:precompile


And the images are compiled, in fact i can see them in the
public/assets/jquery.raty/
directory (where they should be). E.g.

myapp/public/assets/jquery.raty/star-on-4db6f75f3608bbd77fa4bc3959097c33.png


The problem is the gem's javascript cannot find the images because it's referencing to them internally (). So, I've changed the configuration to add the images using <%= asset_path "filename" %> (I changed the file to
.js.erb
). Locally works ok (because I'm not precompiling in development), but after deploying to heroku, the images are referenced like

/assets/jquery.raty/star-on.png


Without the md5 fingerprint.

Somebody knows what am I doing wrong? Or there's something I'm missing when precompilng gem assets?

Thanks.

Answer

Ok, it seems that asset_path doesn't use the fingerprints for the images. I had to use image_path and tweak a little bit to make it work with the library.

Comments