Class: Decidim::Consultations::Admin::ResponseGroupsController
- Inherits:
-
ApplicationController
- Object
- Admin::ApplicationController
- ApplicationController
- Decidim::Consultations::Admin::ResponseGroupsController
- Includes:
- QuestionAdmin
- Defined in:
- app/controllers/decidim/consultations/admin/response_groups_controller.rb
Overview
Controller that manages responses for a question
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/decidim/consultations/admin/response_groups_controller.rb', line 21 def create :create, :response_group, question: current_question @form = response_group_form.from_params(params, current_question: current_question) CreateResponseGroup.call(@form) do on(:ok) do flash[:notice] = I18n.t("response_groups.create.success", scope: "decidim.admin") redirect_to response_groups_path(current_question) end on(:invalid) do flash.now[:alert] = I18n.t("response_groups.create.error", scope: "decidim.admin") render :new end end end |
#destroy ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/controllers/decidim/consultations/admin/response_groups_controller.rb', line 60 def destroy :destroy, :response_group, response_group: current_response_group DestroyResponseGroup.call(current_response_group) do on(:ok) do flash[:notice] = I18n.t("response_groups.destroy.success", scope: "decidim.admin") end on(:invalid) do flash[:alert] = I18n.t("response_groups.destroy.error", scope: "decidim.admin") end redirect_to response_groups_path(current_question) end end |
#edit ⇒ Object
38 39 40 41 |
# File 'app/controllers/decidim/consultations/admin/response_groups_controller.rb', line 38 def edit :update, :response_group, response_group: current_response_group @form = response_group_form.from_model(current_response_group) end |
#index ⇒ Object
12 13 14 |
# File 'app/controllers/decidim/consultations/admin/response_groups_controller.rb', line 12 def index :read, :response_group, question: current_question end |
#new ⇒ Object
16 17 18 19 |
# File 'app/controllers/decidim/consultations/admin/response_groups_controller.rb', line 16 def new :create, :response_group, question: current_question @form = response_group_form.instance end |
#update ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/decidim/consultations/admin/response_groups_controller.rb', line 43 def update :update, :response_group, response_group: current_response_group @form = response_group_form.from_params(params) UpdateResponseGroup.call(current_response_group, @form) do on(:ok) do flash[:notice] = I18n.t("response_groups.update.success", scope: "decidim.admin") redirect_to response_groups_path(current_question) end on(:invalid) do flash.now[:alert] = I18n.t("response_groups.update.error", scope: "decidim.admin") render :edit end end end |