From 3f6f2e9a8c9f7a68b4f85836081229eab814e588 Mon Sep 17 00:00:00 2001 From: reesericci Date: Wed, 7 Feb 2024 07:44:51 +0000 Subject: [PATCH] Scope turbo broadcasts for records to domain --- app/models/record.rb | 6 +++--- app/views/records/index.html.erb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/record.rb b/app/models/record.rb index 9291a03..630f46c 100644 --- a/app/models/record.rb +++ b/app/models/record.rb @@ -37,7 +37,6 @@ def self.create(attributes = {}) obj = new(attributes) obj.validate! obj.save # standard:disable all - obj.broadcast_append_to("records:main", partial: "records/record") obj end @@ -84,13 +83,14 @@ def save if persisted? update_record + broadcast_replace_to(domain, partial: "records/record") else persist + broadcast_append_to(domain, partial: "records/record") end changes_applied - broadcast_replace_to("records:main", partial: "records/record") Rails.cache.delete("records") domain.update!(updated_at: Time.now) # standard:disable all end @@ -105,7 +105,7 @@ def id def destroy! destroy_record - broadcast_remove_to("records:main") + broadcast_remove_to(domain) end def self.destroy_all_host!(host) diff --git a/app/views/records/index.html.erb b/app/views/records/index.html.erb index 05c0187..034e46c 100644 --- a/app/views/records/index.html.erb +++ b/app/views/records/index.html.erb @@ -56,7 +56,7 @@ - <%= turbo_stream_from 'records:main' %> + <%= turbo_stream_from @domain %> <% @records.each do |record| %> <%= render "record", record: record %>