Sha256: d2d651447863103547ea2eed1523fad6bb2890a04b95affef0fe3c83ce0d04c0

Contents?: true

Size: 1.37 KB

Versions: 16

Compression:

Stored size: 1.37 KB

Contents

module Gaku
  class Students::ExtracurricularActivityEnrollmentsController < GakuController

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

    before_action :set_student
    before_action :load_data

    def new
      @extracurricular_activity_enrollment = @student.extracurricular_activity_enrollments.build
      respond_with @extracurricular_activity_enrollment
    end

    def create
      @extracurricular_activity_enrollment = @student.extracurricular_activity_enrollments.create(enrollment_params)
      set_count
      respond_with @extracurricular_activity_enrollment
    end

    def index
      @extracurricular_activity_enrollments = @student.extracurricular_activity_enrollments
    end

    def destroy
      @extracurricular_activity_enrollment = Gaku::Enrollment.find(params[:id])
      @extracurricular_activity_enrollment.destroy!
      set_count
      respond_with @extracurricular_activity_enrollment
    end

    private

    def enrollment_params
      params.require(:enrollment).permit(enrollment_attr)
    end

    def enrollment_attr
      %i( enrollmentable_id )
    end

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

    def set_count
      @count = @student.reload.extracurricular_activities_count
    end

    def load_data
      @extracurricular_activities = Gaku::ExtracurricularActivity.all
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

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