nested new forms #59

Open
miguelsan opened this Issue Jun 24, 2011 · 5 comments

Projects

None yet

6 participants

With the current configuration it is not possible to offer a form with a new parent and its new children, which is a very annoying issue. This due to following:

def child_ancestry
  # New records cannot have children
  raise Ancestry::AncestryException.new('No child ancestry for new record. Save record before performing tree operations.') if new_record?

I am not the only one having this problem: http://stackoverflow.com/questions/6286676/rails-ancestry-nested-form

Thanks for this otherwise great gem.

gshen commented Jan 27, 2012

We also have the same problem which make saving nested new forms impossible, it would be super nice if this can be addressed in the near future.

yxhuvud commented Oct 17, 2012

That can be worked around by making a custom save method that validates all children first and then saves them from the root down. This is pretty simple to do.

A bigger problem is that there is nothing that simulates the ability of accepts_nested_attributes_for - there are neither a children= or children_attributes-method. This end up being pretty icky pretty fast, especially in the case of STI.

gamov commented Jun 10, 2013

I've migrated to ancestry... to run in this issue :(
Reverted back to acts_as_tree.

Collaborator
kbrock commented Feb 15, 2017 edited

The children reference the parent id
But it would seem something as common as belongs_to would implement something similar.

anyone have ideas how acts_as_tree or other plugins implement this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment