Class: Kidspire::Api::V1::RegistrationsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Kidspire::Api::V1::RegistrationsController
- Defined in:
- app/controllers/kidspire/api/v1/registrations_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/kidspire/api/v1/registrations_controller.rb', line 7 def create registration = current_family.registrations.build(registration_params) if registration.save render json: RegistrationBlueprint.render(registration), status: :created else render json: { error: registration.errors..first, code: "validation_error" }, status: :unprocessable_entity end end |
#destroy ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/controllers/kidspire/api/v1/registrations_controller.rb', line 17 def destroy registration = current_family.registrations.find(params[:id]) registration.destroy head :no_content rescue ActiveRecord::RecordNotFound render json: { error: "Registration not found", code: "not_found" }, status: :not_found end |