Method: ActiveType::NestedAttributes::Association#save

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

#save(parent) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/active_type/nested_attributes/association.rb', line 30

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