title: How can I stop faker gem from failing username uniqueness validation in ruby on rails?
body: <p>Using faker to populate my database with fake users and I have a validation rule that makes sure usernames are unique and can't be registered more than once.</p>
  
  <p>When I run rake db:populate it never reaches 1000 it stops sometime before it gets there and because I'm using create! it shows me what I need to see which is: Usernname has already been registered.</p>
  
  <p>My question is there a way I can add a number to the username and each time it comes back round the number increases? That way no username will ever be the same.</p>
  
  <p>e.g.</p>
  
  <p>john1
  pete2
  sally3
  smith4
  luke5
  john6
  sally7</p>
  
  <p>etc... </p>
  
  <p>or is there some other way to make sure no username comes up more than once?</p>
  
  <pre><code> namespace :db do
        namespace :development do
          desc "Create user records in the development database."
          task :populate =&gt; :environment do
            require 'faker'
  
            1000.times do
  
              User.create!(
              :username =&gt; Faker::Internet.user_name,
              :email =&gt; Faker::Internet.email,
              :password =&gt; "greatpasswordhuh"
      )
  
  
            end
          end
        end
      end
  </code></pre>
  
  <p>Kind regards</p>