Use local vars so ivar dependency is only from before actions
This commit is contained in:
@@ -11,17 +11,17 @@ class Cards::Comments::ReactionsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@reaction = @comment.reactions.create!(reaction_params)
|
||||
reaction = @comment.reactions.create!(reaction_params)
|
||||
|
||||
broadcast_create
|
||||
redirect_to card_comment_reactions_path(@comment.card, @comment)
|
||||
broadcast_create(reaction)
|
||||
redirect_to card_comment_reactions_path(@card, @comment)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@reaction = @comment.reactions.find(params[:id])
|
||||
@reaction.destroy
|
||||
reaction = @comment.reactions.find(params[:id])
|
||||
reaction.destroy
|
||||
|
||||
broadcast_remove
|
||||
broadcast_remove(reaction)
|
||||
end
|
||||
|
||||
private
|
||||
@@ -33,12 +33,12 @@ class Cards::Comments::ReactionsController < ApplicationController
|
||||
params.expect(reaction: :content)
|
||||
end
|
||||
|
||||
def broadcast_create
|
||||
@reaction.broadcast_append_to @reaction.comment, :comments,
|
||||
def broadcast_create(reaction)
|
||||
reaction.broadcast_append_to @comment, :comments,
|
||||
target: "reactions_comment_#{@comment.id}", partial: "cards/comments/reactions/reaction", locals: { comment: @comment }
|
||||
end
|
||||
|
||||
def broadcast_remove
|
||||
@reaction.broadcast_remove_to @reaction.comment, :comments
|
||||
def broadcast_remove(reaction)
|
||||
reaction.broadcast_remove_to @comment, :comments
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user