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 %>