Displaying 1 result from an estimated 1 matches for "store_lin".
Did you mean:
store_in
2009 Apr 21
0
Validate order lines on order creation (ActiveResource)
...rchaseOrder < ActiveRecord::Base
has_many :purchase_order_lines
attr_accessor :new_lines
def lines=(_lines)
@new_lines ||= []
_lines.each do |_line_params|
puts _line_params.inspect
@new_lines << PurchaseOrderLine.new(_line_params)
end
end
after_create :store_lines
def store_lines
new_lines.each do |line|
line.purchase_order = self
line.save!
end
end
end
However this does not seem elegant. How can I do it, so that the
creation is done in one call and less custom code needs to be written?
Regards,
Tomasz Bak
--
Posted via http://w...