I'm using turbo_stream to delete my items.
Here is my button :
<%= button_to society_path(society), method: :delete, data:{"turbo-method": :delete, controller: 'confirmation', "confirmation-message-value": 'Souhaitez-vous vraiment supprimer la société ?', action: "confirmation#confirm" }, class:"text-indigo-600 hover:text-indigo-900" do %>
<svg xmlns="http://www.w3.org/2000/svg" class="-ml-1 mr-0.5 flex-shrink-0 self-center h-5 w-5 text-slate-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
<% end %>
Here is my destroy method in my controller :
class SocietiesController < ApplicationController
include ActionView::RecordIdentifier
...
def destroy
@society.destroy
respond_to do |format|
format.html { redirect_to societies_url, notice: "Society was successfully destroyed.", status: :see_other}
format.json { head :no_content }
format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@society))}
end
end
end
The issue is that when I click on the delete button, the item is destroy in my console, but still there in my view as long as I don't refresh. So would know if there is a way to force the refresh of my view after clicking the button
Thank you for your help!