Class: Annotot::AnnotationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Annotot::AnnotationsController
- Defined in:
- app/controllers/annotot/annotations_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /annotations.
-
#destroy ⇒ Object
DELETE /annotations/1.
-
#index ⇒ Object
GET /annotations.
-
#lists ⇒ Object
Get /annotations/lists.
-
#pages ⇒ Object
Get /annotations/pages.
-
#show ⇒ Object
GET /annotations.
-
#update ⇒ Object
PATCH/PUT /annotations/1.
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#index ⇒ Object
GET /annotations
8 9 10 |
# File 'app/controllers/annotot/annotations_controller.rb', line 8 def index @annotations = Annotation.where(canvas: annotation_search_params) end |
#lists ⇒ Object
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 |
#pages ⇒ Object
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 |
#show ⇒ Object
GET /annotations
13 |
# File 'app/controllers/annotot/annotations_controller.rb', line 13 def show; end |
#update ⇒ Object
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 |