Class: Ecm::Courses::CourseCategoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ecm/courses/course_categories_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resource_classObject



3
4
5
# File 'app/controllers/ecm/courses/course_categories_controller.rb', line 3

def self.resource_class
  CourseCategory
end

Instance Method Details

#indexObject



7
8
9
# File 'app/controllers/ecm/courses/course_categories_controller.rb', line 7

def index
  @course_categories = CourseCategory.all
end

#showObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/ecm/courses/course_categories_controller.rb', line 11

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

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

  @course_category = load_resource
  @courses = @course_category.courses.all
  @course_dates = @courses.reduce([]) { |cd, c| cd << c.course_dates.for_month(@date).all }.flatten

  respond_to do |format|
    format.html
    format.ics do
      send_data @course_category.to_icalendar.to_ical, type: 'text/calendar'
    end
  end
end