Class: Kidsmin::Api::V1::ChildrenController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Kidsmin::Api::V1::ChildrenController
- Defined in:
- app/controllers/kidsmin/api/v1/children_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/kidsmin/api/v1/children_controller.rb', line 12 def create child = current_family.children.build(child_params) if child.save render json: ChildBlueprint.render(child), status: :created else render json: { error: child.errors..first, code: "validation_error" }, status: :unprocessable_entity end end |
#destroy ⇒ Object
31 32 33 34 |
# File 'app/controllers/kidsmin/api/v1/children_controller.rb', line 31 def destroy @child.destroy head :no_content end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/kidsmin/api/v1/children_controller.rb', line 8 def index render json: ChildBlueprint.render(current_family.children.order(:first_name, :last_name)) end |
#update ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'app/controllers/kidsmin/api/v1/children_controller.rb', line 22 def update if @child.update(child_params) render json: ChildBlueprint.render(@child) else render json: { error: @child.errors..first, code: "validation_error" }, status: :unprocessable_entity end end |