diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-20 20:57:35 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-20 20:57:35 +0100 |
commit | 4e67f8769a3a3199bfb5b363fe9baa231c329a2b (patch) | |
tree | 3479e67255b6612e1eca50245bb886680d305eb7 /app/controllers | |
parent | a2abe7dffb8fe31687910ca4be6dc0374a247d00 (diff) |
Refactoring
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/tenants_controller.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/app/controllers/tenants_controller.rb b/app/controllers/tenants_controller.rb index 7bb8ecd..cb67e5f 100644 --- a/app/controllers/tenants_controller.rb +++ b/app/controllers/tenants_controller.rb @@ -1,13 +1,17 @@ class TenantsController < ApplicationController - load_and_authorize_resource :tenant + authorize_resource :tenant def index + @tenants = Tenant.scoped end def show + @tenant = Tenant.find(params[:id]) + @gateways = Gateway.order(:updated_at) end def new + @tenant = Tenant.new @tenant.name = generate_a_new_name(@tenant) @tenant.sip_domain = SipDomain.last @tenant.country = GemeinschaftSetup.first.country @@ -18,6 +22,8 @@ class TenantsController < ApplicationController end def create + @tenant = Tenant.new(tenant_params) + if @tenant.save # Become a member of this tenant. # @@ -86,10 +92,12 @@ class TenantsController < ApplicationController end def edit + @tenant = Tenant.find(params[:id]) end def update - if @tenant.update_attributes(params[:tenant]) + @tenant = Tenant.find(params[:id]) + if @tenant.update_attributes(tenant_params) redirect_to @tenant, :notice => t('tenants.controller.successfuly_updated') else render :edit @@ -97,8 +105,15 @@ class TenantsController < ApplicationController end def destroy + @tenant = Tenant.find(params[:id]) @tenant.destroy redirect_to tenants_url, :notice => t('tenants.controller.successfuly_destroyed') end + + private + def tenant_params + params.require(:tenant).permit(:name, :description, :sip_domain_id, :country_id, :language_id, :from_field_pin_change_email, :from_field_voicemail_email +) + end end |