ruby on rails link_to an image -
i'm facing following problem: have small image gallery image files located in following directories
app/assets/images/locale/thumbs/ app/assets/images/locale/big/
i have create hyperlink content has thumb image , target - bigger version app/assets/images/locale/big/ folder:
<a href="path-to-full-size-image-001.jpg"> <img alt="first photo preview" src="/assets/locale/thumbs/001.jpg" /> </a>
i'm doing means of
= link_to(image_tag("locale/thumbs/001.jpg"), "locale/big/spizzicaluna001.jpg")
in fact have tried many variants second argument of link_to little success - bigger file can not found.
how resolve issue?
there 2 approches issue.
you must specify assets folder in path.
link_to( image_tag("locale/thumbs/001.jpg"), "/assets/locale/big/spizzicaluna001.jpg" )
use image path allowing rails find correct image
link_to( image_tag("locale/thumbs/001.jpg"), image_path( "locale/big/spizzicaluna001.jpg") )
more info on image_path:
http://apidock.com/rails/actionview/helpers/assettaghelper/image_path
Comments
Post a Comment