# Models in folders weirdness

**URL:** <https://www.ruby-forum.com/t/models-in-folders-weirdness/142855>\
**Category:** Rails\
**Created:** [July 12, 2008, 5:36am UTC](https://www.ruby-forum.com/t/models-in-folders-weirdness/142855 "2008-07-12T05:36:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcarneiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e36b37/32.png) [@dcarneiro](https://www.ruby-forum.com/u/dcarneiro)\
**Post date:** [July 12, 2008, 5:36am UTC](https://www.ruby-forum.com/t/models-in-folders-weirdness/142855/1 "2008-07-12T05:36:15Z")

</div>

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:

require “#{RAILS\_ROOT}/app/models/image.rb”  
require “#{RAILS\_ROOT}/app/models/group.rb”

# …etc.

What is causing this? Is there a way to fix this besides my ugly  
application.rb hack? Thanks,  
-Daniel
