Not work, multi check and delete This my html form with each list I want delete all checked tasks when click on link
<%= form_tag(_destroy_tasks_path, method: 'put') do %>
<% @tasks.where(active: true).order(:priority).each do |task| %>
<li class="task">
<%= check_box_tag "tasks[]", task.id %>
<%= link_to "Del", _destroy_tasks_path(:id => 'tasks') %>
<%= link_to task.title, task, class: "task-title text-dark" %>
<span class="task-btn">
<%=link_to "", new_status_task_path(task), class: "fas fa-bell text-dark icon" %>
<%= link_to '', edit_task_path(task), class:"fas fa-cogs text-dark mx-2 icon" %>
<%= link_to '', task, method: :delete, data: { confirm: 'Are you sure?' }, class:"far fa-trash-alt text-dark icon" %>
</span>
</li>
<% end %>
<% end %>
Created action:
def _destroy
@task = Task.where(id: params[:tasks])
@task.destroy_all
redirect_to action: "index"
end
Config routes:
resources :tasks do
get :_destroy, on: :collection
end
Please, help me!
Aucun commentaire:
Enregistrer un commentaire