Class: Decidim::Challenges::SurveysController
- Inherits:
-
ApplicationController
- Object
- Decidim::Components::BaseController
- ApplicationController
- Decidim::Challenges::SurveysController
- Includes:
- Forms::Concerns::HasQuestionnaire
- Defined in:
- app/controllers/decidim/challenges/surveys_controller.rb
Overview
Exposes the registration resource so users can answers surveys.
Instance Method Summary collapse
- #after_answer_path ⇒ Object
- #allow_answers? ⇒ Boolean
- #answer ⇒ Object
- #questionnaire_for ⇒ Object
-
#update_url ⇒ Object
You can implement this method in your controller to change the URL where the questionnaire will be submitted.
Instance Method Details
#after_answer_path ⇒ Object
36 37 38 |
# File 'app/controllers/decidim/challenges/surveys_controller.rb', line 36 def after_answer_path challenge_path(challenge) end |
#allow_answers? ⇒ Boolean
32 33 34 |
# File 'app/controllers/decidim/challenges/surveys_controller.rb', line 32 def allow_answers? challenge.survey_enabled? end |
#answer ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/decidim/challenges/surveys_controller.rb', line 9 def answer (:answer, :challenge, challenge:) @form = form(Decidim::Forms::QuestionnaireForm).from_params(params, session_token:) SurveyChallenge.call(challenge, current_user, @form) do on(:ok) do flash[:notice] = I18n.t("surveys.create.success", scope: "decidim.challenges") redirect_to after_answer_path end on(:invalid) do flash.now[:alert] = I18n.t("surveys.create.invalid", scope: "decidim.challenges") render template: "decidim/forms/questionnaires/show" end on(:invalid_form) do flash.now[:alert] = I18n.t("answer.invalid", scope: i18n_flashes_scope) render template: "decidim/forms/questionnaires/show" end end end |
#questionnaire_for ⇒ Object
46 47 48 |
# File 'app/controllers/decidim/challenges/surveys_controller.rb', line 46 def questionnaire_for challenge end |
#update_url ⇒ Object
You can implement this method in your controller to change the URL where the questionnaire will be submitted.
42 43 44 |
# File 'app/controllers/decidim/challenges/surveys_controller.rb', line 42 def update_url answer_challenge_survey_path(challenge_id: challenge.id) end |