Skip to content

Instantly share code, notes, and snippets.

@fabrinal
Created June 1, 2015 12:50
Show Gist options
  • Save fabrinal/683f9c7dd9b6261ca456 to your computer and use it in GitHub Desktop.
Save fabrinal/683f9c7dd9b6261ca456 to your computer and use it in GitHub Desktop.
Add one link to delete photo using ajax
<div class="field">
<%= f.label 'Photos' %><br>
<% 10.times do |i| %>
Photo <%= i + 1 %> &nbsp;
<%= file_field_tag "photos[#{i}]", accept: 'image/png,image/jpeg' %> &nbsp;
<%= @photo_gallery.photos[i].nil? ? '' : label_tag(@photo_gallery.photos[i].image_file_name,nil,id: "photo#{@photo_gallery.photos[i].id}") %> &nbsp;
<!-- add link to delete single photo object below -->
<%= @photo_gallery.photos[i].nil? ? '' : link_to('Hapus Foto',@photo_gallery.photos[i],remote: true, method: :delete,:class => "delete_photo", data: {value: @photo_gallery.photos[i].id}) %><br><br>
<% end %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment