title: generate consecutive unique number in range
body: <p>I have a field in my database to save a unique number adding the last two digits of the created_at year. At the moment it all works well, except instead of using the SecureRandom method i'm looking for an option to save consecutive numbers. ie. 1901, 1902, 1903...</p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>before_create :create_number
  
  def create_number
      loop do
        self. number = ((created_at + 1.year).strftime("%y")).concat(sprintf '%02d', SecureRandom.random_number(200))
        break unless self.class.exists?(:number =&gt; number)
      end
    end
  </code></pre>