Quin
Quin

Reputation: 523

Passing extra parameters via check_box?

Is there a way to pass an id via checkbox?

Let's say we have Model Record which stores information. Any user who want to edit a record will need to propose it first for the Admin to approve. The problem is Record is linked to multiple Image model (with paperclip attachment) so each Record has_many images. The problem is that I am stuck with how to allow users to propose a deletion of existing photos. I imagine it would be great to store a list of proposed deletion, with image_id and proposal_id to store the deletion waiting for approval but I can't find out a way to program the checkbox.

The checkbox would need to pass in the image_id marked to delete. Is it possible and if so how can I do that? Thanks!

Upvotes: 0

Views: 68

Answers (1)

Santhosh
Santhosh

Reputation: 29094

<% @record.images.each do |image| %>
  <%= check_box_tag "image_ids[]", image.id %>
  <%= image_tag image.url %>
<% end %>

Upvotes: 1

Related Questions