action cable
unknown
ruby
2 years ago
419 B
8
Indexable
class CommentsChannel < ApplicationCable::Channel
def subscribed
stream_for @question
end
end
class QuestionsController < ApplicationController
.....
def publish_comment
return if @comment.errors.any?
CommentsChannel.broadcast_to(
@question,
ApplicationController.render(
partial: 'comments/show',
locals: { comment: @comment }
)
)
end
.....
endEditor is loading...
Leave a Comment