Files
mozo-backend/app/models/product_order.rb
T

19 lines
462 B
Ruby

class ProductOrder
include SimplyStored::Couch
property :quantity, type: Fixnum
property :price, type: Float
belongs_to :product
belongs_to :order
view :by_product_id, key: :product_id
view :by_order_id, key: :order_id
# Getter for product name. If a supplier deletes a product, that has product_orders, the product
# will become nil. This method should handle this case.
def product_name
product.try(:name) || '[deleted]'
end
end