Skip to content

Commit

Permalink
Implement nested car and user for all the reservation actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Estete9 committed Feb 24, 2024
1 parent d34d4f9 commit b680507
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/controllers/api/v1/reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def index
render json: {
status: { code: 200, message: 'Reservations fetched successfully.' },
data: @reservations.map do |reservation|
ReservationSerializer.new(reservation).serializable_hash[:data][:attributes]
ReservationWithDetailsSerializer.new(reservation).serializable_hash[:data][:attributes]
end
}, status: :ok
end
Expand All @@ -29,7 +29,7 @@ def create
if @reservation.save
render json: {
status: { code: 201, message: 'Reservation created successfully.' },
data: ReservationSerializer.new(@reservation).serializable_hash[:data][:attributes]
data: ReservationWithDetailsSerializer.new(@reservation).serializable_hash[:data][:attributes]
}, status: :created
else
render json: @reservation.errors, status: :unprocessable_entity
Expand All @@ -41,7 +41,7 @@ def update
if @reservation.update(reservation_params)
render json: {
status: { code: 200, message: 'Reservation updated successfully.' },
data: ReservationSerializer.new(@reservation).serializable_hash[:data][:attributes]
data: ReservationWithDetailsSerializer.new(@reservation).serializable_hash[:data][:attributes]
}, status: :ok
else
render json: @reservation.errors, status: :unprocessable_entity
Expand Down

0 comments on commit b680507

Please sign in to comment.