title: Best practices for multiple models in rails from - nested / non-nested, and validations
body: <p>Note:
  Posting this as a separate question as per Brian's comment (from <a href="https://stackoverflow.com/questions/892624/how-to-handle-multiple-models-in-a-rails-form">how to handle multiple models in a rails form</a>)</p>
  
  <p>I'm trying to learn the best way to handle multiple models in a single rails form, when the models are both nested and non-nested.  For the nested ones, I found these two tutorials to be helpful</p>
  
  <p><a href="http://weblog.rubyonrails.org/2009/1/26/nested-model-forms" rel="nofollow noreferrer">http://weblog.rubyonrails.org/2009/1/26/nested-model-forms</a>
  <a href="http://railsforum.com/viewtopic.php?id=717" rel="nofollow noreferrer">http://railsforum.com/viewtopic.php?id=717</a></p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>In the case of a non-nested model, how to handle multiple entries for the second model?  Just run a loop, and use fields_for?</li>
  <li>In both nested/non-nested cases, how to validate for duplicate values, when there are multiple entries for the second model? For example, if project is the primary and task is the secondary (child) model, and the user adds multiple tasks for the project, how to make sure there aren't duplicate tasks added, for that particular model?
  One way would be to loop through the text values, and check for duplicates.  Is there a better way to do it, at the object level, instead of string level?</li>
  </ol>