Note that there are some explanatory texts on larger screens.

plurals
  1. POrails ancestry nested form
    primarykey
    data
    text
    <p>I've just started using Ancestry instead of awesome_nested_set and I would like to create a nested form so that I can create a parent account and many children accounts all in the one form. The problem seems to be that Ancestry doesn't allow you to create a child for a new parent.</p> <p>In awesome_nested_set I could do this in the rails console</p> <pre><code>a = Account.new a.children.build </code></pre> <p>When I type a.children I can see that new child in there even though my account parent hasn't been created yet. This allowed me to display a form with the parent account and a few blank children, then on submit I would just ignore any blank children and create the whole lot.</p> <p>If I try and do the same using ancestry I get the following error:</p> <pre><code>a=Account.new a.children Ancestry::AncestryException: No child ancestry for new record. Save record before performing tree operations. from /home/map7/.rvm/gems/ruby-1.9.2-p180/gems/ancestry-1.2.4/lib/ancestry/instance_methods.rb:62:in `child_ancestry' from /home/map7/.rvm/gems/ruby-1.9.2-p180/gems/ancestry-1.2.4/lib/ancestry/instance_methods.rb:132:in `child_conditions' from /home/map7/.rvm/gems/ruby-1.9.2-p180/gems/ancestry-1.2.4/lib/ancestry/instance_methods.rb:136:in `children' from (irb):8 from /home/map7/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start' from /home/map7/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start' from /home/map7/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:23:in `&lt;top (required)&gt;' from script/rails:6:in `require' from script/rails:6:in `&lt;main&gt;' </code></pre> <p>Is this a limitation of ancestry? I there a different way in which I could create a nested form using ancestry?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload