Class: Decidim::Meetings::Polls::AnswersController

Inherits:
ApplicationController show all
Includes:
Decidim::Meetings::PollsResources, FormFactory
Defined in:
app/controllers/decidim/meetings/polls/answers_controller.rb

Instance Method Summary collapse

Instance Method Details

#adminObject



12
13
14
# File 'app/controllers/decidim/meetings/polls/answers_controller.rb', line 12

def admin
  enforce_permission_to(:update, :poll, meeting:)
end

#createObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/decidim/meetings/polls/answers_controller.rb', line 20

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

  CreateAnswer.call(@form, 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

#indexObject



16
17
18
# File 'app/controllers/decidim/meetings/polls/answers_controller.rb', line 16

def index
  enforce_permission_to(:reply_poll, :meeting, meeting:)
end