summaryrefslogtreecommitdiff
path: root/app/controllers/serializers
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-03-16 20:36:24 -0600
committerHombreLaser <sebastian-440@live.com>2023-03-16 20:36:24 -0600
commitec60f7fb4be7213174f150318e418cdd8832a39b (patch)
tree03fd80ae3b7f4b0d55578fcc8fe3190eb988916f /app/controllers/serializers
parent5130f549452ead2402a782cbd54667020f196379 (diff)
Añade código de ProductsController
Diffstat (limited to 'app/controllers/serializers')
-rw-r--r--app/controllers/serializers/product_serializer.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/controllers/serializers/product_serializer.rb b/app/controllers/serializers/product_serializer.rb
new file mode 100644
index 0000000..4a2158d
--- /dev/null
+++ b/app/controllers/serializers/product_serializer.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+module Serializers
+ # ProductSerializer
+ class ProductSerializer < BaseSerializer
+ extend ActionView::RoutingUrlFor
+
+ attributes :name, :unitary_price, :bulk_price, :available_quantity, :categories
+
+ attribute :picture do |object|
+ object.picture.url
+ end
+
+ belongs_to :company, links: {
+ self: :url,
+ related: lambda(object) {
+ company_path(object.company)
+ }
+ }
+ end
+end \ No newline at end of file