Skip to content

Commit

Permalink
Optimize queries in bookings and parking_slots controllers to include…
Browse files Browse the repository at this point in the history
… associated records
  • Loading branch information
binos30 committed Jan 16, 2025
1 parent 819ced0 commit 3b2499a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/bookings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class BookingsController < ApiController

# GET /api/v1/bookings or /api/v1/bookings.json
def index
@bookings = Booking.order(:created_at)
@bookings = Booking.includes(:parking_slot).order(:created_at)
end

# GET /api/v1/bookings/1 or /api/v1/bookings/1.json
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/parking_slots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module V1
class ParkingSlotsController < ApiController
# GET /api/v1/parking_slots.json
def index
@parking_slots = ParkingSlot.order(:id)
@parking_slots = ParkingSlot.includes(:parking_lot).order(:id)
end
end
end
Expand Down

0 comments on commit 3b2499a

Please sign in to comment.