Sha256: f1054b5d75eadb8935c8aab426f8bf3615ee9bbb71cb6faf68897520a732b5f5

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

module Gaku
  class ClassGroups::CoursesController < GakuController

    load_and_authorize_resource :class_group, class: ClassGroup
    load_and_authorize_resource :course,
                                through: :class_group,
                                class: Course

    respond_to :html, :js

    inherit_resources

    defaults resource_class: ClassGroupCourseEnrollment,
             instance_name: 'class_group_course_enrollment'



    before_filter :class_group, only: %i(new create edit update destroy)
    before_filter :count,       only: %i(create destroy)

    protected

    def resource_params
      return [] if request.get?
      [params.require(:class_group_course_enrollment).permit(attributes)]
    end

    private

    def attributes
      %i(course_id class_group_id)
    end

    def class_group
      @class_group = ClassGroup.find(params[:class_group_id])
    end

    def count
      @class_group = ClassGroup.find(params[:class_group_id])
      @count = @class_group.courses.count
    end

  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
gaku_core-0.0.3 app/controllers/gaku/class_groups/courses_controller.rb
gaku-0.0.3 core/app/controllers/gaku/class_groups/courses_controller.rb
gaku-0.0.2 core/app/controllers/gaku/class_groups/courses_controller.rb
gaku_core-0.0.2 app/controllers/gaku/class_groups/courses_controller.rb
gaku-0.0.1 core/app/controllers/gaku/class_groups/courses_controller.rb
gaku_core-0.0.1 app/controllers/gaku/class_groups/courses_controller.rb