Refactoring of delivery-workflow. Added ability to add stock_changes after creating a delivery.

This commit is contained in:
Benjamin Meichsner 2009-05-17 16:11:39 +02:00
parent 43fc7b06f8
commit a8e35bd421
7 changed files with 66 additions and 101 deletions

View file

@ -19,7 +19,9 @@ class Delivery < ActiveRecord::Base
validates_presence_of :supplier_id
def stock_change_attributes=(stock_change_attributes)
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