On Aug 8, 2013, at 2:08 PM, Nick Khamis <sym...@gmail.com> wrote:

> 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 
> + "")
> 

can't tell for sure here - but it seems you might have the " and ' reversed in 
the above? 

you have the exterior quotes around the <%=..%> so you just need the string 
value produced by the asset_url, so try:

$('#pic').attr('src', "<%= asset_url(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+unsubscr...@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.
>  
>  

-- 
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+unsubscr...@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/6D7DCDFA-5D3C-4142-BAF1-DA98F63404B6%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to