Class: Gaku::Api::V1::CoursesController

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

Instance Attribute Summary

Attributes inherited from BaseController

#current_user

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
# File 'app/controllers/gaku/api/v1/courses_controller.rb', line 17

def create
  @course = Course.new(course_params)
  if @course.save!
    member_respond_to @course
  end
end

#destroyObject



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

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

#indexObject



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

def index
  @courses = Course.all.page(params[:page ])
  collection_respond_to @courses, root: :courses
end

#showObject



13
14
15
# File 'app/controllers/gaku/api/v1/courses_controller.rb', line 13

def show
  member_respond_to @course
end

#updateObject



24
25
26
27
28
# File 'app/controllers/gaku/api/v1/courses_controller.rb', line 24

def update
  if @course.update!(course_params)
    member_respond_to @course
  end
end