Sha256: 2bbc0536b67c1177217997d127bce7597340886f80a22626b21fdee6ed8b1277
Contents?: true
Size: 1 KB
Versions: 3
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module Decidim module Consultations class QuestionVotesController < Decidim::ApplicationController include NeedsQuestion include Decidim::FormFactory before_action :authenticate_user! def create authorize! :vote, current_question vote_form = form(VoteForm).from_params(params, current_question: current_question) VoteQuestion.call(vote_form) do on(:ok) do current_question.reload render :update_vote_button end on(:invalid) do render json: { error: I18n.t("question_votes.create.error", scope: "decidim.consultations") }, status: 422 end end end def destroy authorize! :unvote, current_question UnvoteQuestion.call(current_question, current_user) do on(:ok) do current_question.reload render :update_vote_button end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems