Class: Decidim::System::AdminsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Decidim::System::AdminsController
- Defined in:
- app/controllers/decidim/system/admins_controller.rb
Overview
Controller that allows managing all the Admins.
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/decidim/system/admins_controller.rb', line 16 def create @form = form(AdminForm).from_params(params) CreateAdmin.call(@form) do on(:ok) do flash[:notice] = I18n.t("admins.create.success", scope: "decidim.system") redirect_to admins_path end on(:invalid) do flash.now[:alert] = I18n.t("admins.create.error", scope: "decidim.system") render :new end end end |
#destroy ⇒ Object
58 59 60 61 62 63 |
# File 'app/controllers/decidim/system/admins_controller.rb', line 58 def destroy @admin = Admin.find(params[:id]).destroy! flash[:notice] = I18n.t("admins.destroy.success", scope: "decidim.system") redirect_to admins_path end |
#edit ⇒ Object
32 33 34 35 |
# File 'app/controllers/decidim/system/admins_controller.rb', line 32 def edit @admin = Admin.find(params[:id]) @form = form(AdminForm).from_model(@admin) end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/decidim/system/admins_controller.rb', line 8 def index @admins = Admin.all end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/decidim/system/admins_controller.rb', line 12 def new @form = form(AdminForm).instance end |
#show ⇒ Object
54 55 56 |
# File 'app/controllers/decidim/system/admins_controller.rb', line 54 def show @admin = Admin.find(params[:id]) end |
#update ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/decidim/system/admins_controller.rb', line 37 def update @admin = Admin.find(params[:id]) @form = form(AdminForm).from_params(params) UpdateAdmin.call(@admin, @form) do on(:ok) do flash[:notice] = I18n.t("admins.update.success", scope: "decidim.system") redirect_to admins_path end on(:invalid) do flash.now[:alert] = I18n.t("admins.update.error", scope: "decidim.system") render :edit end end end |