Class: Kidsmin::Api::V1::RegistrationsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/kidsmin/api/v1/registrations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
# File 'app/controllers/kidsmin/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.full_messages.first, code: "validation_error" },
           status: :unprocessable_entity
  end
end

#destroyObject



17
18
19
20
21
22
23
# File 'app/controllers/kidsmin/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