foodsoft/app/models/delivery.rb
benni 8a74e7d77f Removed annoate and hirb Gemfiles.
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
2012-07-27 18:07:42 +02:00

21 lines
497 B
Ruby

class Delivery < ActiveRecord::Base
belongs_to :supplier
has_one :invoice
has_many :stock_changes, :dependent => :destroy
scope :recent, :order => 'created_at DESC', :limit => 10
validates_presence_of :supplier_id
accepts_nested_attributes_for :stock_changes, :allow_destroy => :true
def new_stock_changes=(stock_change_attributes)
for attributes in stock_change_attributes
stock_changes.build(attributes) unless attributes[:quantity].to_i == 0
end
end
end