title: What would be a good approach to unlimited nested add/edit forms within a rails app/scaffold?
body: <h3>Overview/Models</h3>
  
  <p>Say for example you have a fairly large system with quite generic models (we'll use three for this example)</p>
  
  <ul>
  <li>Locations (generic address fields, type, line1, line2, towncity etc)</li>
  <li>Companies (generic company fields, type, name, etc)</li>
  <li>Contacts (generic contact fields, tpye, name, jobtitle etc)</li>
  </ul>
  
  <h3>Example (+ rails_admin screenshot)</h3>
  
  <p>I find that when making systems like these I always run into the same problem. I click the add button on a company for example (so I've now loaded the form partial etc), I'm part way through adding a company and find that the location I need is not in the system. I want to quickly open up a modal window, add the location and then update the select via jquery or something along those lines. Great, nothing too tough and it's been done in systems like rails_admin (see screenshot below):</p>
  
  <p><a href="http://www.server1-breakfrom.com/nestedaddexample.jpg" rel="nofollow">http://www.server1-breakfrom.com/nestedaddexample.jpg</a></p>
  
  <p>This is all good when dealing with one level of nesting, and generally speaking all good when dealing with this as a rarity (as you can program in the ability as and when). However, I'm doing a system where this almost needs to be a framework in itself as I need it in over 50% of the models. I need the ability to dynamically add the various options in the model/controller and have the forms dynamically generate the relevant buttons.</p>
  
  <h3>Additional Issues</h3>
  
  <ol>
  <li>Modals within/on top of modals - When adding a contact, you click to add their company, within this new companies add form you then want to add a location: boom, modal on top of modal.</li>
  <li>What text to jquery append to the select - You need to know how to update the select element and possibly to find all the relevant select elements on screen. Adding a company will use it's ID and it's name perhaps, but a location will need to use ID along with maybe line1,line2 and towncity for the text.</li>
  <li>Validation within the modal (but I assume we can use some sort of jquery since we're already very dependant on it)</li>
  </ol>
  
  <h3>Expanding the question</h3>
  
  <p>So, in addition to the question: Am I over complicating things and is there an easy to to solve my issue (I must stress the 3 models are purely examples, I have many models that need to reference a company for example, it's not just a contact so 'just program it as you need it', will not work!).</p>
  
  <p>Or, should I just pull apart rails_admin and pull out the bit I need? (Again, they have not solved the multiple nesting issue so I feel a start from scratch might be better?).</p>