ciaoben ciaoben - 1 month ago 9
Ruby Question

Why do I get NameError: uninitialized constant simply making a rake db:create on a new machine

I have a rails app on my virtual machine. environment is development and I work on it regularly. I pulled the code from the repo on a new nserver, and always with

setted to
I called as first command
rake db:migrate
and I get that one of my class is NameError: uninitialized constant.

How is this possible if my code and environment are the same? Autoload on my virtual machine is configured in the right way if it works.

config.autoload_paths << Rails.root.join('lib')
config.autoload_paths += Dir[Rails.root.join('app', 'api', '**', '**', '*')]

And the class that cannot be found is in


Using DKIM as a name will be problematic since the autoloader maps that to d_k_i_m/ in the path. Whenever possible avoid creating directories or files with capital letters in them, it causes chaos on case sensitive filesystems.

app/api/domains/dkim/api.rb should contain Domains::Dkim::Api.

If you want to use some non-standard naming system you'll have to force load your stuff manually, the auto-loader won't do it for you.

The auto-load directive should probably be:

config.autoload_paths << Rails.root.join('app', 'api')

You don't want to be including every single file in your autoload path.