Class: Decidim::System::OrganizationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Decidim::System::OrganizationsController
- Defined in:
- app/controllers/decidim/system/organizations_controller.rb
Overview
Controller to manage Organizations (tenants).
Instance Method Summary collapse
- #create ⇒ Object
-
#current_organization ⇒ Object
The current organization for the request.
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/decidim/system/organizations_controller.rb', line 14 def create @form = form(RegisterOrganizationForm).from_params(params) RegisterOrganization.call(@form) do on(:ok) do flash[:notice] = t("organizations.create.success", scope: "decidim.system") redirect_to organizations_path end on(:invalid) do flash.now[:alert] = t("organizations.create.error", scope: "decidim.system") render :new end end end |
#current_organization ⇒ Object
The current organization for the request.
Returns an Organization.
62 63 64 |
# File 'app/controllers/decidim/system/organizations_controller.rb', line 62 def current_organization @organization end |
#edit ⇒ Object
38 39 40 41 |
# File 'app/controllers/decidim/system/organizations_controller.rb', line 38 def edit organization = Organization.find(params[:id]) @form = form(UpdateOrganizationForm).from_model(organization) end |
#index ⇒ Object
30 31 32 |
# File 'app/controllers/decidim/system/organizations_controller.rb', line 30 def index @organizations = Organization.all end |
#new ⇒ Object
10 11 12 |
# File 'app/controllers/decidim/system/organizations_controller.rb', line 10 def new @form = form(RegisterOrganizationForm).instance end |
#show ⇒ Object
34 35 36 |
# File 'app/controllers/decidim/system/organizations_controller.rb', line 34 def show @organization = Organization.find(params[:id]) end |
#update ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/decidim/system/organizations_controller.rb', line 43 def update @form = form(UpdateOrganizationForm).from_params(params) UpdateOrganization.call(params[:id], @form) do on(:ok) do flash[:notice] = t("organizations.update.success", scope: "decidim.system") redirect_to organizations_path end on(:invalid) do flash.now[:alert] = I18n.t("organizations.update.error", scope: "decidim.system") render :edit end end end |