8a74e7d77f
Annotate: Better look in schema.rb, this reference should be always up to date. Hirb: To reactivate hirb, look in railscasts: http://railscasts.com/episodes/48-console-tricks-revised
14 lines
375 B
Ruby
14 lines
375 B
Ruby
class StockTaking < ActiveRecord::Base
|
|
|
|
has_many :stock_changes, :dependent => :destroy
|
|
has_many :stock_articles, :through => :stock_changes
|
|
|
|
validates_presence_of :date
|
|
|
|
def stock_change_attributes=(stock_change_attributes)
|
|
for attributes in stock_change_attributes
|
|
stock_changes.build(attributes) unless attributes[:quantity].to_i == 0
|
|
end
|
|
end
|
|
end
|
|
|