Files
mozo-backend/app/models/product_order.rb
T
2014-03-30 15:55:22 +02:00

21 lines
528 B
Ruby

class ProductOrder
include SimplyStored::Couch
include ActiveModel::SerializerSupport
property :quantity, type: Fixnum
property :price, type: Float
property :product_name
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