Class: Collavre::Comments::ReactionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Collavre::Comments::ReactionsController
- Includes:
- CommentScoping
- Defined in:
- app/controllers/collavre/comments/reactions_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/collavre/comments/reactions_controller.rb', line 10 def create emoji = params[:emoji].to_s.strip if emoji.blank? render json: { error: I18n.t("collavre.comments.reaction_invalid") }, status: :unprocessable_entity and return end @comment.comment_reactions.find_or_create_by!(user: Current.user, emoji: emoji) broadcast_reaction_update render json: build_reaction_payload end |
#destroy ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/collavre/comments/reactions_controller.rb', line 21 def destroy emoji = params[:emoji].to_s.strip if emoji.blank? render json: { error: I18n.t("collavre.comments.reaction_invalid") }, status: :unprocessable_entity and return end reaction = @comment.comment_reactions.find_by(user: Current.user, emoji: emoji) reaction&.destroy broadcast_reaction_update render json: build_reaction_payload end |