Class: Gaku::TeachersController

Inherits:
GakuController show all
Includes:
PictureController
Defined in:
app/controllers/gaku/teachers_controller.rb

Instance Method Summary collapse

Methods included from PictureController

#remove_picture, #set_picture

Methods included from ClassNameDetector

#class_name, #class_name_minus_enrollment, #class_name_underscored, #class_name_underscored_plural, #enrollment_param

Methods inherited from GakuController

#resolve_layout

Instance Method Details

#createObject



22
23
24
25
26
27
# File 'app/controllers/gaku/teachers_controller.rb', line 22

def create
  @teacher = Teacher.new(teacher_params)
  @teacher.save
  set_count
  respond_with @teacher
end

#destroyObject



11
12
13
14
15
# File 'app/controllers/gaku/teachers_controller.rb', line 11

def destroy
  @teacher.destroy
  set_count
  respond_with @teacher
end

#editObject



29
30
31
# File 'app/controllers/gaku/teachers_controller.rb', line 29

def edit
  respond_with @teacher
end

#indexObject



42
43
44
45
46
47
48
# File 'app/controllers/gaku/teachers_controller.rb', line 42

def index
  @search = Teacher.search(params[:q])
  results = @search.result(distinct: true)
  @teachers = results.page(params[:page])
  set_count
  respond_with @teachers
end

#newObject



17
18
19
20
# File 'app/controllers/gaku/teachers_controller.rb', line 17

def new
  @teacher = Teacher.new
  respond_with @teacher
end

#showObject



33
34
35
# File 'app/controllers/gaku/teachers_controller.rb', line 33

def show
  respond_with @teacher
end

#updateObject



37
38
39
40
# File 'app/controllers/gaku/teachers_controller.rb', line 37

def update
  @teacher.update(teacher_params)
  respond_with @teacher, location: [:edit, @teacher]
end