Method: ActiveType::NestedAttributes::Association#save

Defined in:
lib/active_type/nested_attributes/association.rb

#save(parent) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_type/nested_attributes/association.rb', line 34

def save(parent)
  keep = assigned_children(parent)
  changed_children(parent).each do |child|
    if child.marked_for_destruction?
      child.destroy if child.persisted?
      keep.delete(child)
    else
      child.save(:validate => false) or raise ActiveRecord::Rollback
    end
  end
  assign_children(parent, keep)
end