2014-12-04 18:50:02 +00:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: products
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# name :string(255)
|
|
|
|
# purchase_price :integer
|
|
|
|
# sale_price :integer
|
|
|
|
# img_path :string(255)
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
#
|
|
|
|
|
2014-11-24 20:45:32 +00:00
|
|
|
class Product < ActiveRecord::Base
|
2014-11-29 10:06:22 +00:00
|
|
|
has_one :order_product
|
2014-12-04 18:50:02 +00:00
|
|
|
|
|
|
|
validates :name, presence: true
|
|
|
|
validates :purchase_price, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
|
|
|
validates :sale_price, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
2014-11-24 20:45:32 +00:00
|
|
|
end
|