Sha256: fa4d6ca888f139c14b8d46d2bd2746a9447c0ab3a1a6a5a69e8d624b80229d8d

Contents?: true

Size: 1.04 KB

Versions: 31

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    module Polls
      class AnswersController < Decidim::Meetings::ApplicationController
        include Decidim::Meetings::PollsResources
        include FormFactory

        helper_method :question

        def create
          enforce_permission_to :create, :answer, question: question
          @form = form(AnswerForm).from_params(params, question: question, current_user: current_user)

          CreateAnswer.call(@form, current_user, questionnaire) do
            # Both :ok and :invalid render the same template, because
            # validation errors are displayed in the template
            respond_to do |format|
              format.js
            end
          end
        end

        private

        def question
          @question ||= questionnaire.questions.find(answer_params[:question_id]) if questionnaire
        end

        def answer_params
          params.require(:answer).permit(:question_id, choices: [:body, :answer_option_id])
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-meetings-0.27.9 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.27.8 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.27.7 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.27.6 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.26.10 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.26.9 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.27.5 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.26.8 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.27.4 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.27.3 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.26.7 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.26.5 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.27.2 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.27.1 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.26.4 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.27.0 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.26.3 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.27.0.rc2 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.27.0.rc1 app/controllers/decidim/meetings/polls/answers_controller.rb
decidim-meetings-0.26.2 app/controllers/decidim/meetings/polls/answers_controller.rb