Module: Apique::Editable
Overview
Basic functional for creating, updating, and destroying records.
Instance Method Summary collapse
-
#create ⇒ Object
A resource is already built by CanCan according to load_resource params in the current controller.
-
#destroy ⇒ Object
DELETE /api/plural_resource_name/id.
-
#update ⇒ Object
PATCH/PUT /api/plural_resource_name/id.
Methods included from Pickable
Instance Method Details
#create ⇒ Object
A resource is already built by CanCan according to load_resource params in the current controller. POST /api/plural_resource_name
19 20 21 22 23 24 25 |
# File 'lib/apique/editable.rb', line 19 def create if get_resource.save render json: get_resource, status: :created else render json: {errors: get_resource.errors} end end |
#destroy ⇒ Object
DELETE /api/plural_resource_name/id
37 38 39 40 41 42 43 44 |
# File 'lib/apique/editable.rb', line 37 def destroy get_resource.destroy unless get_resource.errors.present? on_destroy else render json: {errors: get_resource.errors} end end |
#update ⇒ Object
PATCH/PUT /api/plural_resource_name/id
28 29 30 31 32 33 34 |
# File 'lib/apique/editable.rb', line 28 def update if get_resource.update(apique_update_params) render json: get_resource else render json: {errors: get_resource.errors} end end |