Class: Decidim::Kids::Admin::MinorsSpaceController

Inherits:
Admin::ApplicationController
  • Object
show all
Defined in:
app/controllers/decidim/kids/admin/minors_space_controller.rb

Overview

Base Controller that specific participatory spaces should inherit from to limit access to minors.

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/decidim/kids/admin/minors_space_controller.rb', line 18

def create
  @form = form(MinorsSpaceForm).from_params(params)

  SaveParticipatorySpaceConfig.call(@form, current_participatory_space) do
    on(:ok) do
      flash[:notice] = I18n.t("minors_space.save.success", scope: "decidim.kids.admin")
      redirect_to action: :index
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("minors_space.save.error", scope: "decidim.kids.admin", errors: @form&.errors&.messages&.values&.flatten&.first)
      render :index
    end
  end
end

#indexObject



14
15
16
# File 'app/controllers/decidim/kids/admin/minors_space_controller.rb', line 14

def index
  @form = form(MinorsSpaceForm).from_model(current_participatory_space_config)
end