title: Update all record matching some conditions but keeping "position-indexed" values in a database table column
body: <p>I am using Ruby on Rails 3.0.7 and I have a <code>position</code> database table column in order to handle a sortable list of records. I would like to update that column for all records matching some conditions on destroying a record which <code>position</code> value is "in the middle of all position values", but keeping the order (numerically) in the <code>position</code> column. </p>
  
  <p>That is, for example, if in the following list of class objects I destroy the record with <code>position</code> <em>3</em> and <code>user_id</code> <em>1</em></p>
  
  <pre><code>#&lt;Article id: 1, position: 1, user_id: 1&gt;,
  #&lt;Article id: 2, position: 1, user_id: 2&gt;,
  #&lt;Article id: 3, position: 2, user_id: 1&gt;,
  #&lt;Article id: 4, position: 3, user_id: 1&gt;,
  #&lt;Article id: 5, position: 1, user_id: 3&gt;,
  #&lt;Article id: 6, position: 4, user_id: 1&gt;,
  #&lt;Article id: 7, position: 5, user_id: 1&gt;,
  #&lt;...&gt; # A lot of others records having 'user_id' = 1
  </code></pre>
  
  <p>I would like to update all other records related to <code>user_id</code> <em>1</em> so to have</p>
  
  <pre><code>#&lt;Article id: 1, position: 1, user_id: 1&gt;,
  #&lt;Article id: 2, position: 1, user_id: 2&gt;,
  #&lt;Article id: 3, position: 2, user_id: 1&gt;,
  #&lt;Article id: 5, position: 1, user_id: 3&gt;,
  #&lt;Article id: 6, position: 3, user_id: 1&gt;,
  #&lt;Article id: 7, position: 4, user_id: 1&gt;,
  #&lt;...&gt; # A lot of others records having 'user_id' = 1
  </code></pre>
  
  <p>Of course, all that being careful to performance.</p>
  
  <p><strong>How can I do that</strong> (maybe in a single clause\statement)<strong>?</strong></p>
  
  <hr>
  
  <p>I know that the <code>update_all</code> method can help someway, but I don't know how to auto-increment <code>position</code> values using that.</p>