olwen_demo_app/app/controllers/admin/accounting_zones_controller.rb
Nicolas Bally 7b2e6811dd initial
2020-06-05 11:10:02 +02:00

66 lines
1.0 KiB
Ruby

# -*- encoding : utf-8 -*-
class Admin::AccountingZonesController < ApplicationController
layout "admin"
before_action :auth_admin
before_action :admin_space
def admin_space
@admin_space = "preferences"
end
def index
@accounting_zones = AccountingZone.order(:name).all
end
def show
@accounting_zone = AccountingZone.find(params[:id])
end
def new
@accounting_zone = AccountingZone.new
end
def edit
@accounting_zone = AccountingZone.find(params[:id])
end
def create
@accounting_zone = AccountingZone.new(params.require(:accounting_zone).permit!)
if @accounting_zone.save
else
render action: "new"
end
end
def update
@accounting_zone = AccountingZone.find(params[:id])
if @accounting_zone.update_attributes(params.require(:accounting_zone).permit!)
else
render action: "edit"
end
end
def destroy
@accounting_zone = AccountingZone.find(params[:id])
@accounting_zone.destroy
end
end