Sha256: 5d3a266ec646924ed44dafa8d3fafc4afc1cf11a04b57c5b4a956b3a5710899f

Contents?: true

Size: 1021 Bytes

Versions: 16

Compression:

Stored size: 1021 Bytes

Contents

module Gaku
  class Admin::DepartmentsController < Admin::BaseController

    respond_to :js,   only: %i( new create edit update destroy index )

    before_action :set_department, only: %i( edit update destroy )

    def index
      @departments = Department.all
      set_count
      respond_with @departments
    end

    def new
      @department = Department.new
      respond_with @department
    end

    def create
      @department = Department.new(department_params)
      @department.save
      set_count
      respond_with @department
    end

    def edit
    end

    def update
      @department.update(department_params)
      respond_with @department
    end

    def destroy
      @department.destroy
      set_count
      respond_with @department
    end

    private

    def set_department
      @department = Department.find(params[:id])
    end

    def department_params
      params.require(:department).permit(:name)
    end

    def set_count
      @count = Department.count
    end

  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
gaku_admin-0.3.0 app/controllers/gaku/admin/departments_controller.rb
gaku_admin-0.3.0.pre.4 app/controllers/gaku/admin/departments_controller.rb
gaku_admin-0.3.0.pre.3 app/controllers/gaku/admin/departments_controller.rb
gaku_admin-0.3.0.pre.2 app/controllers/gaku/admin/departments_controller.rb
gaku_admin-0.3.0.pre.1 app/controllers/gaku/admin/departments_controller.rb
gaku_admin-0.3.0.pre.0 app/controllers/gaku/admin/departments_controller.rb
gaku-0.2.4 admin/app/controllers/gaku/admin/departments_controller.rb
gaku_admin-0.2.4 app/controllers/gaku/admin/departments_controller.rb
gaku-0.2.3 admin/app/controllers/gaku/admin/departments_controller.rb
gaku_admin-0.2.3 app/controllers/gaku/admin/departments_controller.rb
gaku-0.2.2 admin/app/controllers/gaku/admin/departments_controller.rb
gaku_admin-0.2.2 app/controllers/gaku/admin/departments_controller.rb
gaku-0.2.1 admin/app/controllers/gaku/admin/departments_controller.rb
gaku_admin-0.2.1 app/controllers/gaku/admin/departments_controller.rb
gaku-0.2.0 admin/app/controllers/gaku/admin/departments_controller.rb
gaku_admin-0.2.0 app/controllers/gaku/admin/departments_controller.rb