Sha256: a0d3e747be42dadfa1d6c6b8b8159a4eb75e7f83c775ff8c43cf3f44ee14708c

Contents?: true

Size: 1.74 KB

Versions: 16

Compression:

Stored size: 1.74 KB

Contents

module Gaku
  class ExtracurricularActivitiesController < GakuController

    include StudentChooserController

    respond_to :html, :js

    before_action :set_extracurricular_activity, only: %i( edit show update student_chooser destroy )

    def destroy
      @extracurricular_activity.destroy
      set_count
      respond_with @extracurricular_activity
    end

    def new
      @extracurricular_activity = ExtracurricularActivity.new
      respond_with @extracurricular_activity
    end

    def create
      @extracurricular_activity = ExtracurricularActivity.new(extracurricular_activity_params)
      @extracurricular_activity.save
      set_count
      respond_with @extracurricular_activity
    end

    def edit
    end

    def show
    end

    def update
      @extracurricular_activity.update(extracurricular_activity_params)
      respond_with @extracurricular_activity, location: [:edit, @extracurricular_activity]
    end

    def index
      @search = ExtracurricularActivity.search(params[:q])
      results = @search.result(distinct: true)
      @extracurricular_activities = results.page(params[:page])
      set_count
      respond_with @extracurricular_activities
    end

    private

    def extracurricular_activity_params
      params.require(:extracurricular_activity).permit(attributes)
    end

    def attributes
      %i( name )
    end

    def set_extracurricular_activity
      @extracurricular_activity = ExtracurricularActivity.find(params[:id])
      set_enrollmentable
    end

    def set_enrollmentable
      @enrollmentable = @extracurricular_activity
      @enrollmentable_resource = @enrollmentable.class.to_s.demodulize.underscore.dasherize
    end

    def set_count
      @count = ExtracurricularActivity.count
    end

  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

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