Class: Decidim::Assemblies::Admin::AssembliesController
- Inherits:
-
Decidim::Admin::ApplicationController
- Object
- Decidim::Admin::ApplicationController
- Decidim::Assemblies::Admin::AssembliesController
- Defined in:
- app/controllers/decidim/assemblies/admin/assemblies_controller.rb
Overview
Controller that allows managing assemblies.
Instance Method Summary collapse
- #copy ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Instance Method Details
#copy ⇒ Object
74 75 76 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 74 def copy :create, Decidim::Assembly end |
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 22 def create :new, Decidim::Assembly @form = form(AssemblyForm).from_params(params) CreateAssembly.call(@form) do on(:ok) do flash[:notice] = I18n.t("assemblies.create.success", scope: "decidim.admin") redirect_to assemblies_path end on(:invalid) do flash.now[:alert] = I18n.t("assemblies.create.error", scope: "decidim.admin") render :new end end end |
#destroy ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 65 def destroy :destroy, current_assembly current_assembly.destroy! flash[:notice] = I18n.t("assemblies.destroy.success", scope: "decidim.admin") redirect_to assemblies_path end |
#edit ⇒ Object
39 40 41 42 43 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 39 def edit :update, current_assembly @form = form(AssemblyForm).from_model(current_assembly) render layout: "decidim/admin/assembly" end |
#index ⇒ Object
12 13 14 15 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 12 def index :index, Decidim::Assembly @assemblies = collection end |
#new ⇒ Object
17 18 19 20 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 17 def new :new, Decidim::Assembly @form = form(AssemblyForm).instance end |
#update ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/decidim/assemblies/admin/assemblies_controller.rb', line 45 def update :update, current_assembly @form = form(AssemblyForm).from_params( assembly_params, assembly_id: current_assembly.id ) UpdateAssembly.call(current_assembly, @form) do on(:ok) do |assembly| flash[:notice] = I18n.t("assemblies.update.success", scope: "decidim.admin") redirect_to edit_assembly_path(assembly) end on(:invalid) do flash.now[:alert] = I18n.t("assemblies.update.error", scope: "decidim.admin") render :edit, layout: "decidim/admin/assembly" end end end |