Sha256: 3f3e8a56f1f30c66d7fd6862125de6fa845cdca30a4edf20e3b09b57eeede747

Contents?: true

Size: 1.27 KB

Versions: 16

Compression:

Stored size: 1.27 KB

Contents

module Gaku
  class Admin::CampusesController < Admin::BaseController
    include AdminPictureController

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

    before_action :set_campus, only:   %i( edit update destroy )
    before_action :set_school, except: %i( set_picture remove_picture )

    def destroy
      @campus.destroy
      set_count
      respond_with @campus
    end

    def new
      @campus = Campus.new
      respond_with @campus
    end

    def create
      @campus = Campus.new(campus_params)
      @campus.save
      @school.campuses << @campus
      set_count
      respond_with @campus
    end

    def edit
      respond_with @campus
    end

    def update
      @campus.update(campus_params)
      respond_with @campus
    end

    def index
      @campuses = Campus.all
      set_count
      respond_with @campus
    end

    private

    def campus_params
      params.require(:campus).permit(attributes)
    end

    def attributes
      %i( name school_id master picture )
    end

    def set_school
      @school = School.find(params[:school_id])
    end

    def set_campus
      @campus = Campus.find(params[:id])
    end

    def set_count
      @count = @school.campuses.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/campuses_controller.rb
gaku_admin-0.3.0.pre.4 app/controllers/gaku/admin/campuses_controller.rb
gaku_admin-0.3.0.pre.3 app/controllers/gaku/admin/campuses_controller.rb
gaku_admin-0.3.0.pre.2 app/controllers/gaku/admin/campuses_controller.rb
gaku_admin-0.3.0.pre.1 app/controllers/gaku/admin/campuses_controller.rb
gaku_admin-0.3.0.pre.0 app/controllers/gaku/admin/campuses_controller.rb
gaku-0.2.4 admin/app/controllers/gaku/admin/campuses_controller.rb
gaku_admin-0.2.4 app/controllers/gaku/admin/campuses_controller.rb
gaku-0.2.3 admin/app/controllers/gaku/admin/campuses_controller.rb
gaku_admin-0.2.3 app/controllers/gaku/admin/campuses_controller.rb
gaku-0.2.2 admin/app/controllers/gaku/admin/campuses_controller.rb
gaku_admin-0.2.2 app/controllers/gaku/admin/campuses_controller.rb
gaku-0.2.1 admin/app/controllers/gaku/admin/campuses_controller.rb
gaku_admin-0.2.1 app/controllers/gaku/admin/campuses_controller.rb
gaku-0.2.0 admin/app/controllers/gaku/admin/campuses_controller.rb
gaku_admin-0.2.0 app/controllers/gaku/admin/campuses_controller.rb