Files
fizzy/app/controllers/cards/comments/reactions_controller.rb
T
David Heinemeier Hansson 7861b7c087 Just open one turbo stream per card
Per comment is excessive and needless
2025-04-11 17:58:11 +02:00

45 lines
988 B
Ruby

class Cards::Comments::ReactionsController < ApplicationController
include CardScoped
before_action :set_comment
def index
@reactions = @comment.reactions.includes(:reacter).ordered
end
def new
end
def create
reaction = @comment.reactions.create!(reaction_params)
broadcast_create(reaction)
redirect_to card_comment_reactions_path(@card, @comment)
end
def destroy
reaction = @comment.reactions.find(params[:id])
reaction.destroy
broadcast_remove(reaction)
end
private
def set_comment
@comment = @card.comments.find(params[:comment_id])
end
def reaction_params
params.expect(reaction: :content)
end
def broadcast_create(reaction)
reaction.broadcast_append_to @card,
target: "reactions_comment_#{@comment.id}", partial: "cards/comments/reactions/reaction", locals: { comment: @comment }
end
def broadcast_remove(reaction)
reaction.broadcast_remove_to @card
end
end