title: Rails unique column has duplicates
body: <p>This is the stripped down version of my model . </p>
  
  <pre><code>model Paper
    PAPER_STARTING_NUMBER = 1
  
    validate_uniqueness_of :number, :allow_blank =&gt; true
    before_create :alocate_paper_number
  
    def alocate_paper_number
      return true if self.number.present?
      p_number = Paper.maximum('number') || Paper::PAPER_STARTING_NUMBER 
      self.number = p_number &gt;= Paper::PAPER_STARTING_NUMBER ? p_number+1 : Paper::PAPER_STARTING_NUMBER 
      return true 
    end
  end
  </code></pre>
  
  <p>the problem is I have duplicates in the number column .
  Any ideas why and how I can fix this without changing the callback . 
  I know I could add a uniqueness validation on the database or make a sequence on that column , any other ideas ?</p>