From b03bb338ef36a140338a0d4723bafa719021a808 Mon Sep 17 00:00:00 2001 From: Yaro Date: Thu, 11 Nov 2021 18:36:04 +0000 Subject: [PATCH] remove messages --- app/controllers/messages_controller.rb | 2 ++ app/views/layouts/application.html.erb | 1 + app/views/messages/_message.html.erb | 1 + 3 files changed, 4 insertions(+) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index fb3b778..c111512 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -71,6 +71,8 @@ def update def destroy @message.destroy respond_to do |format| + format.turbo_stream { render turbo_stream: turbo_stream.remove(@message) } + # format.turbo_stream { render turbo_stream: turbo_stream.remove("message_#{@message.id}") } format.html { redirect_to messages_url, notice: "Message was successfully destroyed." } format.json { head :no_content } end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index bf5fe5f..c8f7238 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,6 +10,7 @@ + <%= Time.zone.now %> <%= yield %> diff --git a/app/views/messages/_message.html.erb b/app/views/messages/_message.html.erb index e3b4fd4..efd8443 100644 --- a/app/views/messages/_message.html.erb +++ b/app/views/messages/_message.html.erb @@ -6,5 +6,6 @@

<%= link_to "Show this message", message %> + <%= button_to "Destroy this message", message_path(message), method: :delete %>