2014-12-04 18:50:02 +00:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: order_products
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# order_id :integer
|
|
|
|
# product_id :integer
|
|
|
|
# count :integer default(1)
|
|
|
|
#
|
|
|
|
|
2014-11-25 13:27:27 +00:00
|
|
|
class OrderProduct < ActiveRecord::Base
|
|
|
|
belongs_to :order
|
|
|
|
belongs_to :product
|
2014-12-04 16:02:08 +00:00
|
|
|
|
2014-12-04 18:50:02 +00:00
|
|
|
validates :product, presence: true
|
|
|
|
validates :count, numericality: { greater_than_or_equal_to: 0 }
|
|
|
|
|
2014-12-04 16:02:08 +00:00
|
|
|
accepts_nested_attributes_for :product
|
2014-11-25 13:27:27 +00:00
|
|
|
end
|