title: Best practices to save models that are related with a foreign key
body: <p>There is a scenario like this, I have a model <code>Project</code> and this project has a gallery of <code>Image</code>s. So:</p>
  
  <pre><code>Project HAS_MANY Image
  Image BELONGS_TO Project -&gt; Foreign key: project_id
  </code></pre>
  
  <p>In a form I want to be able to save project information and multiple images all together. The problem is that how can I get the <code>project_id</code> since the model <code>Project</code> has a id that is auto-increment and I have no access to it before saving the model.</p>
  
  <p>One way that I thought about is to dummy save the model in the begining then after user submits the form updating it. But it seems very nasty!</p>
  
  <p>What are the best practices to save models with HAS_MANY and BELONGS_TO relationships in the same form?</p>