I'm creating an image gallery website, and have some problems. I tried searching, but it's hard because i cannot really describe this problem.
i want to have thumbnail images on my index page, but i can't get it working.
why does this code inside /views/index.html.erb
<% @galleries.each do |gallery| %>
<%= image_tag gallery.photos(:small).last %>
<%= link_to gallery.title, gallery_path(gallery) %>
doesn't show me photos, just blank spaces where photos supposed to appear. When i right click on them to open in new tab, it links to /images/#..... and gives No routes error.
On show.html.erb pictures are shown with this code:
<% @gallery.photos.each do |photo|%>
<%= image_tag photo.image(:medium) %>
<% end %>
models are: gallery has many photos, photos belongs to gallery.
gallery controller: def index @galleries = Gallery.all.order(created_at: :desc) end
def show
@gallery = Gallery.find(params[:id])
end
routes: resources :galleries resources :photos