Class: Annotot::AnnotationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/annotot/annotations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /annotations



26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/annotot/annotations_controller.rb', line 26

def create
  @annotation = Annotation.new(annotation_params)

  if @annotation.save
    render json: @annotation.data
  else
    render status: :bad_request, json: {
      message: 'An annotation could not be created'
    }
  end
end

#destroyObject

DELETE /annotations/1



51
52
53
54
55
56
# File 'app/controllers/annotot/annotations_controller.rb', line 51

def destroy
  @annotation.destroy
  render status: :ok, json: {
    message: 'Annotation was successfully destroyed.'
  }
end

#indexObject

GET /annotations



8
9
10
# File 'app/controllers/annotot/annotations_controller.rb', line 8

def index
  @annotations = Annotation.where(canvas: annotation_search_params)
end

#listsObject

Get /annotations/lists



16
17
18
# File 'app/controllers/annotot/annotations_controller.rb', line 16

def lists
  @annotations = Annotation.where(canvas: annotation_search_params)
end

#pagesObject

Get /annotations/pages



21
22
23
# File 'app/controllers/annotot/annotations_controller.rb', line 21

def pages
  @annotations = Annotation.where(canvas: annotation_search_params)
end

#showObject

GET /annotations



13
# File 'app/controllers/annotot/annotations_controller.rb', line 13

def show; end

#updateObject

PATCH/PUT /annotations/1



39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/annotot/annotations_controller.rb', line 39

def update
  if @annotation.update(annotation_params)
    render status: :ok, json: @annotation.data
  else
    render status: :bad_request, json: {
      message: 'Annotation could not be updated.',
      status: :bad_request
    }
  end
end