views:

656

answers:

2

I have this on line 56 in my environment.rb: I18n.load_path += Dir[ File.join(RAILS_ROOT, 'lib', 'locale', '*.{rb,yml}') ]

I can run the app just fine, but when I try to run: script/generate migration

I get this error: environment.rb:56: uninitialized constant I18n (NameError)

What gives?

+1  A: 

By default, active_support (where the I18n module is located) is not loaded in your environment.rb. The proper way to add directories to your i18n load path is by the following in your environment.rb:

config.i18n.load_path << Dir[File.join(RAILS_ROOT, 'my', 'locales', '*.{rb,yml}')]

I think, as an alternative, you might be able to throw in a require 'active_support' before your reference to the I18n module in your environment.rb, but it doesn't seem like a good idea.

swenson
A: 

Thanks. The line I used was copy/pasted bad code from a tutorial.

So by using

config.i18n.load_path

instead of

I18n.load_path

I got rid of the error.

Lau