Skip to content

Commit 66848cf

Browse files
committed
real time CRUD for quotes
1 parent 5973298 commit 66848cf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/models/quote.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@ class Quote < ApplicationRecord
77
# - how to limit access / specify policy for channels?
88
# - how to test
99
# after_create_commit -> { broadcast_prepend_to "quotes", target: "quotes", partial: "quotes/quote", locals: { quote: self } }
10-
after_create_commit -> { broadcast_prepend_to "quotes" }
10+
# after_create_commit -> { broadcast_prepend_later_to "quotes" }
11+
# after_update_commit -> { broadcast_replace_later_to "quotes" }
12+
# Can't use self.id to broadcast later.
13+
# after_destroy_commit -> { broadcast_remove_to "quotes" }
14+
# The above three callbacks are equivalent to the following single line
15+
broadcasts_to ->(quote) { "quotes" }, inserts_by: :prepend
1116
end

0 commit comments

Comments
 (0)