LETTERLIJK 1 LIJN

This commit is contained in:
tl3ilaxu 2016-03-01 15:25:44 +01:00
parent a88dd7d4c0
commit 18ea5ad627
1 changed files with 1 additions and 3 deletions

View File

@ -13,9 +13,7 @@ class OrderItem < ActiveRecord::Base
belongs_to :product
validates :product, presence: true
validates :count, presence: true, numericality: { only_integer: true,
less_than_or_equal_to: ->(oi) { oi.product.try(:stock) || 100 },
greater_than_or_equal_to: 0 }
validates :count, presence: true, numericality: { only_integer: true }
before_destroy :put_back_in_stock!
after_create :remove_from_stock!