Class: Decidim::Consultations::QuestionMultipleVotesController

Inherits:
ApplicationController
  • Object
show all
Includes:
NeedsQuestion, FormFactory
Defined in:
app/controllers/decidim/consultations/question_multiple_votes_controller.rb

Instance Method Summary collapse

Methods included from NeedsQuestion

enhance_controller, extended, included

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/decidim/consultations/question_multiple_votes_controller.rb', line 20

def create
  enforce_permission_to :vote, :question, question: current_question

  multivote_form = form(MultiVoteForm).from_params(params, current_question: current_question)

  MultipleVoteQuestion.call(multivote_form, current_user) do
    on(:ok) do
      redirect_to question_path(current_question)
    end

    on(:invalid) do |_form, error|
      flash[:error] = I18n.t("question_votes.create.error", scope: "decidim.consultations")
      flash[:error] << " (#{error})" if error
      redirect_to question_question_multiple_votes_path
    end
  end
end

#showObject

Non-ajax votings (such as multi-reponses) have a html page



15
16
17
18
# File 'app/controllers/decidim/consultations/question_multiple_votes_controller.rb', line 15

def show
  enforce_permission_to :vote, :question, question: current_question
  @form = form(MultiVoteForm).instance(current_question: current_question)
end