Some of my models are in folders to add some organization to what will
eventually be hundreds of models. Somewhere I read that if you put
config.load_paths += Dir[RAILS_ROOT + ‘/app/models/*/’]
in your environment.rb file, everything will get loaded correctly, but
that is not the case.
This actually causes many strange problems. For instance, occasionally I
get errors because multiple instantiations of the same model have been
created when I only expected one. I also get errors that seem to suggest
that rails is misjudging the model’s name because of its inclusion in a
folder. That is, rails will report that it could not find User::User
when the user.rb model is in the user folder.
Interestingly, my application works exactly as expected if, in addition
to the above, I explicitly require each model file in application.rb:
What is causing this? Is there a way to fix this besides my ugly
application.rb hack? Thanks,