title: How to solve duplicate records in my rails app
body: <p>We use Formtastic and built add_fields / remove_fields for one to many association models based on this <a href="http://railscasts.com/episodes/197-nested-model-form-part-2" rel="nofollow noreferrer">railscasts</a>. Now we are encountering a duplicate entries problem. Say, after we create a new project, and then edit this project with 3 tasks loaded, if I add one more task when editing, this new added task is duplicated in database.</p>
  
  <p>We also use update_attributes to check validation and AJAX to submit the form and run the process in the background job in sidekiq.</p>
  
  <p>And I found this <a href="https://stackoverflow.com/questions/18946479/ror-nested-attributes-produces-duplicates-when-edit">link</a>, but I'm using rails 3.2. Not sure what I can do for this case...</p>
  
  <p>Has anyone met this problem before? I'm now trying to post my codes here.(too complicated to simplify posting here hehe)</p>
  
  <p><strong>UPDATE</strong>
  So after a long investigation of this problem, we found the double entry is caused by submitting AJAX twice. </p>