Load Paths


Hello ~

I was under the impression that Rails looped through the folders in
your app adding classes dynamically. For example I have:


After moving my files into these folders, our app died. I got it to
work again by adding the paths to the environment.rb in the
config.load_paths. Is there an option I am missing which will do this
automatically? My load_paths is going to get very long.


~ Ben

Ben R.


I’m not totally sure on this, but I think that Rails assumes that if
you have a model in a subfolder, then it’s part of a module. For
example, if you have a layout like
| subfolder
| MyModel.rb

Then you would need to change the class declaration in MyModel.rb to
subfolder::MyModel, because Rails will think that MyModel is in the
‘subfolder’ namespace.

As I said, I’m not sure about this, but I think that’s the case.