Class: Decidim::Surveys::SurveysController
- Inherits:
-
ApplicationController
- Object
- Components::BaseController
- ApplicationController
- Decidim::Surveys::SurveysController
- Includes:
- FormFactory
- Defined in:
- app/controllers/decidim/surveys/surveys_controller.rb
Overview
Exposes the survey resource so users can view and answer them.
Instance Method Summary collapse
Instance Method Details
#answer ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/decidim/surveys/surveys_controller.rb', line 15 def answer :answer, :survey @form = form(SurveyForm).from_params(params) AnswerSurvey.call(@form, current_user, survey) do on(:ok) do flash[:notice] = I18n.t("surveys.answer.success", scope: "decidim.surveys") redirect_to survey_path(survey) end on(:invalid) do flash.now[:alert] = I18n.t("surveys.answer.invalid", scope: "decidim.surveys") render action: "show" end end end |
#show ⇒ Object
11 12 13 |
# File 'app/controllers/decidim/surveys/surveys_controller.rb', line 11 def show @form = form(SurveyForm).from_model(survey) end |