instructors_controller.rb 442 Bytes
Newer Older
Zac Wood's avatar
Zac Wood committed
1 2
class InstructorsController < ApplicationController
  def index
3
    @instructors = Instructor.all
Zac Wood's avatar
Zac Wood committed
4 5 6
  end

  def show
Zac Wood's avatar
Zac Wood committed
7
    @instructor = Instructor.find_by_id(params[:id])
8

Zac Wood's avatar
Zac Wood committed
9
    # find the courses being taught this semester
Zac Wood's avatar
Zac Wood committed
10 11 12
    sections = CourseSection.where(instructor: @instructor)
    @semesters = sections.group_by do |s|
      s.semester.to_s
13
    end
Zac Wood's avatar
Zac Wood committed
14 15

    @rating = { teaching: @instructor.rating, respect: @instructor.rating(6) }
16
  end
Zac Wood's avatar
Zac Wood committed
17
end