Class: Decidim::Comments::VotesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/decidim/comments/votes_controller.rb

Overview

Controller that manages the comment votes.

Instance Method Summary collapse

Methods inherited from ApplicationController

#permission_class_chain

Instance Method Details

#createObject

Raises:

  • (ActionController::RoutingError)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/decidim/comments/votes_controller.rb', line 13

def create
  raise ActionController::RoutingError, "Not Found" unless comment

  enforce_permission_to :vote, :comment, comment: comment

  Decidim::Comments::VoteComment.call(comment, current_user, weight: params[:weight].to_i) do
    on(:ok) do
      respond_to do |format|
        format.js { render :create }
      end
    end
    on(:invalid) do
      respond_to do |format|
        format.js { render :error }
      end
    end
  end
end