title: Create a copy of an object and all its associated models in rails
body: <p>I am working on creating a copy of an object in rails and all its related associated models. But i am unable to figure out a solution for that. I don't want to use any gem like <strong>Amoeba</strong>. The relationships between the models is something like this.<br /></p>
  
  <pre><code>class ClassToCopy
      has_many :cups
      has_many :cup_parts, through :cups
      belongs_to :xyz
  end
  </code></pre>
  
  <p>So i want to keep a button like copy ClassToCopy and on clicking on that should create a new copy of that object with all the associations along with it. Like if an object of ClassToCopy has 10 cups and 4 cup_parts then corresponding objects of those classes should also be created.
  I have tried out using <strong>clone</strong> and <strong>dup</strong> (using rails 3.2.x), but clone doesn't create a new object from the original one and dup doesn't allow associations. Hence am confused what to do.</p>