Class: Decidim::Proposals::ProposalVotesController

Inherits:
ApplicationController show all
Includes:
ProposalVotesHelper
Defined in:
app/controllers/decidim/proposals/proposal_votes_controller.rb

Overview

Exposes the proposal vote resource so users can vote proposals.

Instance Method Summary collapse

Methods included from ProposalVotesHelper

#remaining_votes_count_for, #vote_button_classes, #vote_limit_enabled?, #votes_count_classes

Instance Method Details

#createObject



13
14
15
16
17
18
19
# File 'app/controllers/decidim/proposals/proposal_votes_controller.rb', line 13

def create
  authorize! :vote, proposal

  proposal.votes.create!(author: current_user)
  @from_proposals_list = params[:from_proposals_list] == "true"
  render :update_buttons_and_counters
end

#destroyObject



21
22
23
24
25
26
27
# File 'app/controllers/decidim/proposals/proposal_votes_controller.rb', line 21

def destroy
  authorize! :unvote, proposal

  proposal.votes.where(author: current_user).delete_all
  @from_proposals_list = params[:from_proposals_list] == "true"
  render :update_buttons_and_counters
end