Class: Gaku::Api::V1::StudentsController

Inherits:
BaseController show all
Defined in:
app/controllers/gaku/api/v1/students_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#current_user

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @student = Student.new(create_student_params)
  if @student.save!
    member_respond_to @student
  end
end

#destroyObject



35
36
37
38
39
# File 'app/controllers/gaku/api/v1/students_controller.rb', line 35

def destroy
  if @student.destroy!
    member_respond_to @student
  end
end

#indexObject



9
10
11
12
# File 'app/controllers/gaku/api/v1/students_controller.rb', line 9

def index
  @students = Student.includes(:primary_contact, :primary_address).all
  collection_respond_to @students, root: :students
end

#pictureObject



14
15
16
# File 'app/controllers/gaku/api/v1/students_controller.rb', line 14

def picture
  send_file @student.picture.path
end

#showObject



18
19
20
# File 'app/controllers/gaku/api/v1/students_controller.rb', line 18

def show
  member_respond_to @student
end

#updateObject



29
30
31
32
33
# File 'app/controllers/gaku/api/v1/students_controller.rb', line 29

def update
  if @student.update!(update_student_params)
    member_respond_to @student
  end
end