# frozen_string_literal: true # CartSerializer class CartSerializer < BaseSerializer attribute :products do |object| ProductSerializer.new( Product.joins(:product_carts).select('products.*', 'product_carts.quantity AS quantity') .includes(picture_attachment: :blob).where('product_carts.cart_id = ?', object.id) ).serializable_hash end end