0

I'm looking at this documentation, and I'm having trouble coming up with a solution in creating checkboxes to my images, but associated to the form?

If you see below, my images are looped inside the form...

edit view

<%= simple_form_for @project, html: { multipart: true } do |f| %>

  <% @project.project_images.each do |img| %>
    <%= attachment_image_tag(img, :file, :fit, 1000, 430) %>
  <% end %>

  <%= f.attachment_field :trip_images_files, multiple: true %>
  <%= f.button :submit %>
<% end %>

I can add <%= f.check_box :remove_project_images %> inside the .each loop?

  <% @project.project_images.each do |img| %>
    <%= attachment_image_tag(img, :file, :fit, 1000, 430) %>
    <%= f.check_box :remove_project_images_files %>
  <% end %>

Actually, at the time of writing this.. I'm getting undefined method 'remove_project_images_files', now I'm not even sure at all.

hellomello
  • 8,219
  • 39
  • 151
  • 297
  • What is the exact error message? and did you permit `:remove_project_images_files` in your `strong_params` method? – Pavan Jul 22 '15 at 07:15
  • Hi @Pavan! Yeah, I included that in my strong_params. I have these included: `:remove_project_images_files, project_images_files: []`... the last one is like that because of multiple upload images per the documentation. I'm just getting `undefined method`. But if I do attach that to the loop, how does the form know which image its attached to? Since it'll just loop as many check boxes based on the images, but won't really have any data attached to it to let the server know which image to delete – hellomello Jul 22 '15 at 07:20

0 Answers0