Class: Decidim::Comments::VotesController

Inherits:
ApplicationController show all
Defined in:
decidim-comments/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

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from Headers::HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

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 'decidim-comments/app/controllers/decidim/comments/votes_controller.rb', line 13

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

  enforce_permission_to(:vote, :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