byCoder
byCoder

Reputation: 9184

Rails access folder in public folder

I have such structure(for example):

 public
   art_im
     folder1
        img01.jpg

what i need to write, to access this img01.jpg in tag? i try

= image_tag("#{Rails.root}/public/art_im/images_#{@graphics.id}/#{@grp.id}.jpg", :alt => "#{@art.nr}")

but i get in html <img alt="lalala" src="/home/prog/project/Shop/public/art_im/images_32/214800.jpg">

but how to link on my server, and get this images?

Upvotes: 6

Views: 19411

Answers (1)

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230561

When your app is run by webserver, its webroot will be the public directory. So, this should work:

= image_tag("/art_im/images_#{@graphics.id}/#{@grp.id}.jpg", :alt => "#{@art.nr}")

Upvotes: 8

Related Questions