title: how do I disassociate a record from an activerecord association without deleting the record?
body: <p>How do I disassociate a record from an association without deleting the record?</p>
  
  <p>Consider the following scenario, a <code>Game</code> has many <code>rules</code> and a <code>rule</code> has many <code>Games</code> so</p>
  
  <pre><code>&gt;&gt; game.rules   #=&gt; [#&lt;rule id: 1, ...&gt;,  #&lt;rule id:2, ...&gt;]
  </code></pre>
  
  <p>how do I disassociate the rule of id 2 from <code>game</code> without deleting it, so the relation ends up like this:</p>
  
  <pre><code>&gt;&gt; game.rules   #=&gt; [#&lt;rule id: 1, ...&gt;]
  </code></pre>
  
  <p>I tried reassigning an updated array to the relation, however that's preventing the association from saving future insertions somehow. I believe one can't assign arrays to relations.</p>
  
  <p>This is what I've tried:</p>
  
  <pre><code>&gt;&gt; tmp = game.rules.to_a
  &gt;&gt; tmp.delete(rule_of_id2)
  &gt;&gt; game.rules = tmp
  ^D
  </code></pre>
  
  <p>but then, future insertions does not persist.</p>
  
  <pre><code>&gt;&gt; games.rules &lt;&lt; new_rule_of_id3
  ^D
  
  &gt;&gt; game.rules   #=&gt; [#&lt;rule id: 1, ...&gt;
  </code></pre>
  
  <p>It shoult return   <code>#=&gt; [#&lt;rule id: 1, ...&gt;, #&lt;rule id: 3, ...&gt;]</code></p>
  
  <p>how can I update the relation without explicitly deleting a <code>rule</code>.</p>