Home>

app/assets/imagesI want to display all the .JPG images in the browser.
I wrote the following code, but an error has occurred in the image_tag part of View.

controller

def index
    @pictures = Dir.glob ("app/assets/images/*. JPG")
end


View

<% @ pictures.each do | pic |%>
 <% = image_tag pic%>
<% end%>

I would like to know what is wrong.
I look forward to working with you.

  • Answer # 1

    app/assets/imagesWhat is inimage_tag file nameIt's fine.
    So
    @pictures = Dir.glob ("* .JPG", base: "app/assets/images")

Related articles