summaryrefslogtreecommitdiff
path: root/app/models
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/models
parent5130f549452ead2402a782cbd54667020f196379 (diff)
Añade código de ProductsController
Diffstat (limited to 'app/models')
-rw-r--r--app/models/product.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/product.rb b/app/models/product.rb
index 72d7f33..87a7a71 100644
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -21,5 +21,17 @@ class Product < ApplicationRecord
has_one_attached :picture
+ around_create :generate_public_id
+
serialize :categories, Array
+
+ def to_param
+ public_id
+ end
+
+ private
+
+ def generate_public_id
+ self.public_id = SecureRandom.hex(12)
+ end
end