Sha256: 3a3eea6722d9711e02c5d04cfd320c8d7fe80754506d7d26d1ee90ce6a0dcb66

Contents?: true

Size: 1.22 KB

Versions: 16

Compression:

Stored size: 1.22 KB

Contents

module Gaku
  class StudentSelectionController < GakuController

    respond_to :js,             only: %i( index add remove clear )
    before_action :user_selection
    before_action :set_student, only: %i( add remove )
    before_action :set_students, only: %i( collection remove_collection )

    def add
      @selection = @user_selection.add(@student)
      respond_with @selection
    end

    def remove
      @selection = @user_selection.remove(@student)
      set_count
      respond_with @selection
    end

    def collection
      @selection = @user_selection.collection(@students)
      render 'index'
    end

    def remove_collection
      @selection = @user_selection.remove_collection(@students)
      render 'index'
    end

    def index
      @selection = @user_selection.students
    end

    def clear
      @selection = @user_selection.remove_all
      respond_with @selection
    end

    private

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

    def set_students
      @students = Student.where(id: params[:student_ids])
    end

    def set_count
      @count = @selection.count
    end

    def user_selection
      @user_selection = Gaku::StudentSelection.new(current_user)
    end

  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

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