title: Rails: Insert a resource and at the same time being able to insert subresources
body: <p>I'm a Rails beginner. </p>
  
  <p>I have a problem with it, but first, here's an image to explain what I want to do:</p>
  
  <p><img src="https://i.stack.imgur.com/YSGwF.png" alt="Wireframe"></p>
  
  <p><em>Verbally</em>: I'm struggling to have a new page for a resource, where I can add —inside it— associated subresources. </p>
  
  <p>When I click on <code>add new subresource</code>, I'd like to get on the  <strong>new page</strong> for the subresource. After clicking on save, with the field completed, I should get redirected back to the new resource page, and I should see inside it the newly associated subresource.</p>
  
  <p>I tried to insert this line of code in the resource new form:</p>
  
  <pre><code>link_to 'New Sub Resource', new_resource_sub_resource_path(@resource)
  </code></pre>
  
  <p>But when I click, it returns something like:</p>
  
  <pre><code>No route matches {:resource_id=&gt;nil} missing required keys: [:resource_id]
  </code></pre>
  
  <p>Clearly, the resource is not still saved so it complains because it doesn't have an Id... is this solvable? If so, how?</p>