instructors_controller.rb 537 Bytes
Newer Older
Zac Wood's avatar
Zac Wood committed
1
class InstructorsController < ApplicationController
2
3
  before_action :set_instructor, only: [:show]

Zac Wood's avatar
Zac Wood committed
4
  def index
5
    @instructors = Instructor.all
Zac Wood's avatar
Zac Wood committed
6
7
8
  end

  def show
9
    sections = CourseSection.where instructor: @instructor
Zac Wood's avatar
Zac Wood committed
10
11
12
    sections = sections.select do |s|
      s.course.semester == @semester
    end
13
14
15
16
17
18
19
20
21
22
23
24

    # TODO: move this to a model somewhere
    @courses = [].to_set
    sections.each do |s|
      @courses.add s.course
    end
  end

  private

  def set_instructor
    @instructor = Instructor.find_by_id params[:id]
Zac Wood's avatar
Zac Wood committed
25
26
  end
end