Sha256: fa2ff3d0f824d593d75578f3d056e1ac75479d5f3daaffa843711def25605113

Contents?: true

Size: 1.54 KB

Versions: 16

Compression:

Stored size: 1.54 KB

Contents

module Gaku
  class Admin::GradingMethodSetsController < Admin::BaseController

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

    before_action :set_grading_method_set, only: %i( edit update show destroy make_primary )

    def index
      @grading_method_sets = GradingMethodSet.all
      set_count
      respond_with @grading_method_sets
    end

    def new
      @grading_method_set = GradingMethodSet.new
      respond_with @grading_method_set
    end

    def create
      @grading_method_set = GradingMethodSet.new(grading_method_set_params)
      @grading_method_set.save
      set_count
      respond_with @grading_method_set
    end

    def edit
    end

    def show
    end

    def update
      @grading_method_set.update(grading_method_set_params)
      respond_with @grading_method_set
    end

    def destroy
      GradingMethodSet.first.try(:make_primary) if @grading_method_set.primary?
      @grading_method_set.destroy
      set_count
      respond_with @grading_method_set
    end

    def make_primary
      @grading_method_set.make_primary
      respond_with @grading_method_set
    end

    private

    def set_grading_method_set
      @grading_method_set = GradingMethodSet.find(params[:id])
    end

    def grading_method_set_params
      params.require(:grading_method_set).permit(attributes)
    end

    def attributes
      %i( display_deviation display_rank name primary rank_order )
    end

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