[Rails] Images with fingerprinting
Looking through the asset pipeline documentation, I was able to make everything
-- work as expected. Really nice!! However, not for images that we are loading using
a variable (i.e., wine.picture) which basically resolves to (bold_nine.jpg). First
question, is it possible to use (asset_path) and pass variables?
From the little bit of searching I found that (asset_path) does not support variables,
and we should use (asset_url) instead. My concern is production env and the fingerprinting
of images. Some observation:
$('#pic').attr('src', "<%= asset_url('block_nine.jpg')%>") ------correctly yields-----> $('#pic').attr('src', "/assets/block_nine-b3cebc2ed66a8605caae943eacdd358d.jpg")
$('#pic').attr('src', "<%= asset_url('" + wine.pictures + "')%>") ---------incorrectly yields-------> $('#pic').attr('src', "/" + wine.pictures + "")
Error in console:
ActionController::RoutingError (No route matches [GET] "/block_nine.jpg")
That being said,
$('#pic').attr('src', "<%= asset_url('assets/" + wine.picture + "')%>"); $('#pic').attr('src', "<%= asset_path('assets/" + wine.picture + "')%>");
both work in development and production however, I think at that point I am serving up the images from
assets and not the web server using the fingerprints as intended.
Your help is greatly appreciate,
Nick.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/17d2a0d5-07df-4a76-8bed-048df49b4400%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home