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.
-
#update ⇒ Object
PATCH/PUT /annotations/1.
Instance Method Details
#create ⇒ Object
POST /annotations
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/annotot/annotations_controller.rb', line 13 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
38 39 40 41 42 43 |
# File 'app/controllers/annotot/annotations_controller.rb', line 38 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 |
#update ⇒ Object
PATCH/PUT /annotations/1
26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/annotot/annotations_controller.rb', line 26 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 |