Sha256: 9b223f7c23efecf84970107f977649e83448e559115c549076246824afa910c1

Contents?: true

Size: 843 Bytes

Versions: 10

Compression:

Stored size: 843 Bytes

Contents

module Ecm::Courses
  class CoursesController < Ecm::Courses::ApplicationController
    def self.resource_class
      Course
    end

    def calendar
      @year  = params[:year]  ||= Time.zone.now.year
      @month = params[:month] ||= Time.zone.now.month

      @date = Date.strptime("#{@month}-#{@year}", "%m-%Y")

      @course = load_resource
      @course_dates = @course.course_dates.for_month(@date).all
    end
    
    def index
      @courses = load_collection
    end
    
    def show
      @course = load_resource
    end

    private

    def load_collection
      load_scope.all
    end

    def resource_class
      self.class.resource_class
    end

    def load_scope
      resource_class.includes(:course_category, :course_dates)
    end

    def load_resource
      load_scope.friendly.find(params[:id])
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ecm_courses2-1.1.4 app/controllers/ecm/courses/courses_controller.rb
ecm_courses2-1.1.3 app/controllers/ecm/courses/courses_controller.rb
ecm_courses2-1.1.2 app/controllers/ecm/courses/courses_controller.rb
ecm_courses2-1.1.1 app/controllers/ecm/courses/courses_controller.rb
ecm_courses2-1.1.0 app/controllers/ecm/courses/courses_controller.rb
ecm_courses2-1.0.3 app/controllers/ecm/courses/courses_controller.rb
ecm_courses2-1.0.2 app/controllers/ecm/courses/courses_controller.rb
ecm_courses2-1.0.1 app/controllers/ecm/courses/courses_controller.rb
ecm_courses2-1.0.0 app/controllers/ecm/courses/courses_controller.rb
ecm_courses2-0.2.4 app/controllers/ecm/courses/courses_controller.rb