Displayin wrong modal image

Good afternoon,

I’m trying to deploy the following. When the user select one image, this one is open in a modal window, but each image that is tiggered by the user opens the same picture. The first one.

Here is the code:

<% cache ['photos', Photo.latest] do %> <% @photos.each do |photo| %> <% if @user_home.id == photo.user_id %> <% if photo.avatar_file_name == nil %> <%= image_tag 'missing.png', class:'img-gallery', id:'image'%> <% else %> <%= image_tag photo.avatar.url, class:'img-gallery', id:'img-click' , remote:true %>
<%= image_tag photo.avatar.url, class:'img-gallery'%> Close
<% end %> <% end %>
    <% end %>
<% end %>

Could anyone tell me what I’m doing wrong?.

Thanks & Best regards