# frozen_string_literal: true # OrderSerializer class OrderSerializer < BaseSerializer attributes :public_id, :created_at attribute :products do |object| ProductSerializer.new( Product.joins(:product_order).select('products.*', 'product_orders.quantity AS quantity') .includes(picture_attachment: :blob).where('product_orders.order_id = ?', object.id) ).serializable_hash end attribute :total do |object| object.payment.total end end