title: Extending Faker gem locally uninitialized constant Faker::xxx
body: <p>I want to extend the faker gem for rails to also generate other random date (in my case computer game names)</p>
  
  <pre><code>#lib/extended_faker.rb
  require 'faker'
  require 'extended_faker/game'
  
  #lib/extended_faker/game.rb
  Module Faker
      class Game &lt; Faker::Base
          class &lt;&lt; self
              def name
                  fetch('game.name')
              end
          end
      end
  end
  
  #config/locals/faker_en.yml
  en:
    faker:
      game:
        name: ["a", "b", "c"]
  
  #config/application.rb
  ...
  config.autoload_paths += Dir["#{config.root}/lib/**/"]
  ...
  </code></pre>
  
  <p>then when i run it in a rails console i get the following</p>
  
  <pre><code>Loading development environment (Rails 3.2.9)
  1.9.3p194 :001 &gt; Faker::Game.name
  LoadError: Expected /home/enermis/School/Projects/IG/test/lib/extended_faker/game.rb to define Game
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:503:in `load_missing_constant'
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:192:in `block in const_missing'
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:190:in `each'
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:190:in `const_missing'
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:514:in `load_missing_constant'
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:192:in `block in const_missing'
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:190:in `each'
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:190:in `const_missing'
      from (irb):1
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands/console.rb:47:in `start'
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in `start'
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands.rb:41:in `&lt;top (required)&gt;'
      from script/rails:6:in `require'
      from script/rails:6:in `&lt;main&gt;'
  </code></pre>
  
  <p>When i change the lib/extended_faker/game.rb file to this</p>
  
  <pre><code>require 'faker'
  require 'extended_faker/game'
  include 'extended_faker/item'
  include 'extended_faker/team'
  </code></pre>
  
  <p>i get weird behavior in the console</p>
  
  <pre><code>Loading development environment (Rails 3.2.9)
  1.9.3p194 :001 &gt; Faker::Game.name
   =&gt; "b" 
  1.9.3p194 :002 &gt; Faker::Game.name
  NameError: uninitialized constant Faker::Game
      from (irb):2
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands/console.rb:47:in `start'
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in `start'
      from /home/enermis/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands.rb:41:in `&lt;top (required)&gt;'
      from script/rails:6:in `require'
      from script/rails:6:in `&lt;main&gt;'
  </code></pre>
  
  <p>The weird thing i don't understand is that the first time i run the generator, i get a valid result, but the second time around i get an error...</p>
  
  <p>What am i missing?</p>