diff options
author | HombreLaser <sebastian-440@live.com> | 2023-04-06 13:29:17 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2023-04-06 13:29:17 -0600 |
commit | b7455b581022059a87633864c2ac2751b035e1e1 (patch) | |
tree | 30c9afae248c52b32af394d22a172c7c007d7a49 /app/serializers/cart_serializer.rb | |
parent | 4e3d24a5c68e3ab951fe0cf388bdc2ea1fdc050e (diff) |
Añadido controlador de carrito
Diffstat (limited to 'app/serializers/cart_serializer.rb')
-rw-r--r-- | app/serializers/cart_serializer.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/serializers/cart_serializer.rb b/app/serializers/cart_serializer.rb new file mode 100644 index 0000000..cbe46d8 --- /dev/null +++ b/app/serializers/cart_serializer.rb @@ -0,0 +1,11 @@ +# 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 |