# frozen_string_literal: true # Product # public_id:string # name:string # unitary_price:float # bulk_price:float # picture:attachment # available_quantity:integer # categories:text class Product < ApplicationRecord belongs_to :company has_many :product_reviews validates :name, presence: true validates :unitary_price, presence: true validates :unitary_price, comparison: { greater_than: 0 } validates :bulk_price, presence: true validates :bulk_price, comparison: { greater_than: 0 } validates :available_quantity, presence: true validates :available_quantity, comparison: { greater_than: 0 } has_one_attached :picture serialize :categories, Array def to_param public_id end end