vendredi 16 septembre 2016

Rails - Delete a specific item only if the checkbox is checked

I am trying to delete a tweet from my model only if the checkbox aside is checked.

Here is a screenshot:

enter image description here

Here is the beginning of the code in my view:

<% @twits.each do |twit| %>
  <li>
    <%= link_to "#{twit.link}", twit_path(twit) %> | Engagement => <%= twit.engagement %> | <%= twit.like %> likes | <%= twit.retweet %> retweets | on <%= twit.first_date %>
    <%= check_box_tag("delete[#{twit.id}]",1) %> -
    <%= link_to twit_path(twit) do %>
      <i class="glyphicon glyphicon-eye-open"></i>
    <% end %> -
    <%= link_to twit_path(twit), method: :delete do %>
      <i class="glyphicon glyphicon-trash"></i>
    <% end %>
  </li>
<% end %>

Thanks for your help!




Aucun commentaire:

Enregistrer un commentaire