James Duncan Davidson has written up a frustrating experience where he learned Rails Sometimes Eats Class Load Errors.
After the trouble debugging the issue, James suggests:
Use require what you need where you need it. I tend to do this in my code all the time, probably from the habit of using include and import in other languages which are a bit pickier about such things. But, from now on, I’ll be prompting others to do this as well in Ruby, especially when using Rails. Don’t trust environment.rb. There’s too much magic there.
It is interesting to hear this, when on the other hand you learn about the new dependency management in Edge Rails.
Edge Rails lets you put code in yourappproject/mystuff/foo.rb in the package Mystuff::Foo and it is all loaded for you. This means that you can do LESS require-ing.
However, there does seem to be a bit too magic going on here, and I often forget the order of when things are loaded, which can be very painful indeed.
I wonder if someone has written up the dependency cycle of Rails so we can print it and put it on the wall :)