Sha256: 0246cc5e21fa2144f7d2e79bf0cc2c7bd1b408c0e0c635bd3481ea53ec27786c

Contents?: true

Size: 1.17 KB

Versions: 16

Compression:

Stored size: 1.17 KB

Contents

module Gaku
  class Students::BadgesController < GakuController

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

    before_action :set_student
    before_action :set_badge, only: %i( edit update destroy )
    before_action :set_badge_types,        only: %i( new edit )

    def new
      @badge = Badge.new
      respond_with @badge
    end

    def create
      @badge = @student.badges.create!(badge_params)
      set_count
      respond_with @badge
    end

    def edit
      respond_with @badge
    end

    def update
      @badge.update(badge_params)
      respond_with @badge
    end

    def destroy
      @badge.destroy
      set_count
      respond_with @badge
    end

    def index
      @badges = @student.badges
      set_count
      respond_with @badges
    end

    private

    def badge_params
      params.require(:badge).permit(:badge_type_id)
    end

    def set_badge_types
      @badge_types = BadgeType.all
    end

    def set_student
      @student = Student.find(params[:student_id]).decorate
    end

    def set_badge
      @badge = Badge.find(params[:id])
    end

    def set_count
      @count = @student.badges.count
    end

  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
gaku_frontend-0.3.0 app/controllers/gaku/students/badges_controller.rb
gaku_frontend-0.3.0.pre.4 app/controllers/gaku/students/badges_controller.rb
gaku_frontend-0.3.0.pre.3 app/controllers/gaku/students/badges_controller.rb
gaku_frontend-0.3.0.pre.2 app/controllers/gaku/students/badges_controller.rb
gaku_frontend-0.3.0.pre.1 app/controllers/gaku/students/badges_controller.rb
gaku_frontend-0.3.0.pre.0 app/controllers/gaku/students/badges_controller.rb
gaku-0.2.4 frontend/app/controllers/gaku/students/badges_controller.rb
gaku_frontend-0.2.4 app/controllers/gaku/students/badges_controller.rb
gaku-0.2.3 frontend/app/controllers/gaku/students/badges_controller.rb
gaku_frontend-0.2.3 app/controllers/gaku/students/badges_controller.rb
gaku-0.2.2 frontend/app/controllers/gaku/students/badges_controller.rb
gaku_frontend-0.2.2 app/controllers/gaku/students/badges_controller.rb
gaku-0.2.1 frontend/app/controllers/gaku/students/badges_controller.rb
gaku_frontend-0.2.1 app/controllers/gaku/students/badges_controller.rb
gaku-0.2.0 frontend/app/controllers/gaku/students/badges_controller.rb
gaku_frontend-0.2.0 app/controllers/gaku/students/badges_controller.rb