I am struggling with sending multiple items to the trash folder using checkboxes. I get an
undefined method `move_to_trash' for #<Array:0x007...etc...
move_to_trash
works fine on single conversations.
I have a checkbox next to each conversation rendered by a partial, and a button to delete all checked conversations.
Anyway, my conversations controller:
def trash_multiple
@convo = mailbox.conversations.find(params[:trash_id])
@convo.move_to_trash(current_user)
redirect_to mailbox_inbox_path
end
The checkbox which is in a partial, placed next to each conversation:
<%= check_box_tag "trash_id[]", conversation.id %>
The id's are correct.
The form:
<div class="message-cont">
<div class="col-md-8">
<%= form_tag trash_multiple_conversations_path, method: :post do %>
<%= submit_tag "Trash selected" %>
<div class="panel-body">
<% if is_conversation %>
<%= render 'conversations/form' %>
<% else %>
<div class="msg-cnter">
<%= render partial: 'conversations/conversation', collection: messages %>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
And my routes:
resources :conversations do
member do
post :reply
post :trash
post :untrash
end
collection do
get :trashbin
post :empty_trash
post :trash_multiple
end
end
Any hints on getting this to work for an array would be greatly appreciated, thanks.
Aucun commentaire:
Enregistrer un commentaire