tap/app/models/order_product.rb
2014-12-04 19:50:02 +01:00

20 lines
470 B
Ruby

# == Schema Information
#
# Table name: order_products
#
# id :integer not null, primary key
# order_id :integer
# product_id :integer
# count :integer default(1)
#
class OrderProduct < ActiveRecord::Base
belongs_to :order
belongs_to :product
validates :order, presence: true
validates :product, presence: true
validates :count, numericality: { greater_than_or_equal_to: 0 }
accepts_nested_attributes_for :product
end