ruby on rails link_to an image

前端 未结 1 1367
南旧
南旧 2020-12-06 01:23

I\'m facing the following problem: I have a very small image gallery with image files located in the following directories

 app/assets/images/locale/thumbs/
         


        
相关标签:
1条回答
  • 2020-12-06 02:06

    There are two approches to this issue.

    1. You must specify the assets folder in the path.

      link_to( image_tag("locale/thumbs/001.jpg"), "/assets/locale/big/spizzicaluna001.jpg" )

    2. Use an image path allowing rails to find the 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

    0 讨论(0)
提交回复
热议问题