Skip to content

Commit 9df1959

Browse files
committed
fix(api): Eager-load ActiveStorage attachments in orders endpoint
Thread Spree::Asset.attachment_preloads through find_order so variant image URLs in the order JSON response don't N+1 under ActiveStorage.
1 parent 00d4062 commit 9df1959

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

api/app/controllers/spree/api/orders_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def permitted_payment_attributes
170170

171171
def find_order(_lock = false)
172172
@order = Spree::Order
173-
.includes(line_items: [:adjustments, {variant: :images}],
173+
.includes(line_items: [:adjustments, {variant: {images: Spree::Image.attachment_preloads}}],
174174
payments: :payment_method,
175175
shipments: {
176176
shipping_rates: {shipping_method: :zones, taxes: :tax_rate}

0 commit comments

Comments
 (0)