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.