foodsoft/app/models/stock_change.rb

19 lines
392 B
Ruby
Raw Normal View History

class StockChange < ActiveRecord::Base
belongs_to :delivery
belongs_to :order
2012-10-17 20:45:52 +02:00
belongs_to :stock_article, with_deleted: true
validates_presence_of :stock_article_id, :quantity
validates_numericality_of :quantity
after_save :update_article_quantity
after_destroy :update_article_quantity
protected
def update_article_quantity
stock_article.update_quantity!
end
end