Class: Decidim::Initiatives::Admin::InitiativesTypeScopesController
- Inherits:
-
ApplicationController
- Object
- Admin::ApplicationController
- ApplicationController
- Decidim::Initiatives::Admin::InitiativesTypeScopesController
- Includes:
- TranslatableAttributes
- Defined in:
- app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb
Overview
Controller used to manage the available initiative type scopes
Instance Method Summary collapse
-
#create ⇒ Object
POST /admin/initiatives_types/:initiatives_type_id/initiatives_type_scopes.
-
#destroy ⇒ Object
DELETE /admin/initiatives_types/:initiatives_type_id/initiatives_type_scopes/:id.
-
#edit ⇒ Object
GET /admin/initiatives_types/:initiatives_type_id/initiatives_type_scopes/:id/edit.
-
#new ⇒ Object
GET /admin/initiatives_types/:initiatives_type_id/initiatives_type_scopes/new.
-
#update ⇒ Object
PUT /admin/initiatives_types/:initiatives_type_id/initiatives_type_scopes/:id.
Methods inherited from ApplicationController
#permission_class_chain, #permissions_context
Instance Method Details
#create ⇒ Object
POST /admin/initiatives_types/:initiatives_type_id/initiatives_type_scopes
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb', line 22 def create :create, :initiative_type_scope @form = initiative_type_scope_form .from_params(params, type_id: params[:initiatives_type_id]) CreateInitiativeTypeScope.call(@form) do on(:ok) do |initiative_type_scope| flash[:notice] = I18n.t("decidim.initiatives.admin.initiatives_type_scopes.create.success") redirect_to edit_initiatives_type_path(initiative_type_scope.type) end on(:invalid) do flash.now[:alert] = I18n.t("decidim.initiatives.admin.initiatives_type_scopes.create.error") render :new end end end |
#destroy ⇒ Object
DELETE /admin/initiatives_types/:initiatives_type_id/initiatives_type_scopes/:id
65 66 67 68 69 70 71 72 |
# File 'app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb', line 65 def destroy :destroy, :initiative_type_scope, initiative_type_scope: current_initiative_type_scope current_initiative_type_scope.destroy! redirect_to edit_initiatives_type_path(current_initiative_type_scope.type), flash: { notice: I18n.t("decidim.initiatives.admin.initiatives_type_scopes.destroy.success") } end |
#edit ⇒ Object
GET /admin/initiatives_types/:initiatives_type_id/initiatives_type_scopes/:id/edit
41 42 43 44 |
# File 'app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb', line 41 def edit :edit, :initiative_type_scope, initiative_type_scope: current_initiative_type_scope @form = initiative_type_scope_form.from_model(current_initiative_type_scope) end |
#new ⇒ Object
GET /admin/initiatives_types/:initiatives_type_id/initiatives_type_scopes/new
16 17 18 19 |
# File 'app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb', line 16 def new :create, :initiative_type_scope @form = initiative_type_scope_form.instance end |
#update ⇒ Object
PUT /admin/initiatives_types/:initiatives_type_id/initiatives_type_scopes/:id
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb', line 47 def update :update, :initiative_type_scope, initiative_type_scope: current_initiative_type_scope @form = initiative_type_scope_form.from_params(params) UpdateInitiativeTypeScope.call(@form, current_initiative_type_scope) do on(:ok) do flash[:notice] = I18n.t("decidim.initiatives.admin.initiatives_type_scopes.update.success") redirect_to edit_initiatives_type_path(resource.type) end on(:invalid) do flash.now[:alert] = I18n.t("decidim.initiatives.admin.initiatives_type_scopes.update.error") render :edit end end end |