Wes Gamble wrote:
THE REAL ANSWER:
application.rb is now loaded as part of the call to the "Rails::Initializer.run" block in environment.rb, and it wasn't in pre-2.1 versions of Rails.
In this case, application.rb had dependencies that is was requiring.
These libraries, which were require'd in application.rb in turn had dependencies that were not being "required in" until the end of environment.rb.
Before this worked because environment.rb would be run before application.rb (the first time application.rb would be loaded was on the first request).
But now, if application.rb needs anything to be loaded, you must either:
1) Ensure that the full dependency tree is satisfied in application.rb itself
2) Require in those lower level dependencies before the "Rails::Initializer.run" block in environment.rb.
THE FINAL ANSWER:
1) create an /initializers folder inside RAILS_ROOT/config
2) create a application.rb file inside that folder and move all your 'requires' into it.
If you create a new rails project under 2.1 and look at what it does in your environment.rb and in the initializers folder you'll see the Rails 2.1 way this kind of this is supposed to be handled.
My understanding is that you can create any/as many .rb files inside of initializers that you want (to separate different needs) and they'll all be loaded. So, you could have an initializers/foo_feature.rb and an initializers/bar_extensions.rb, etc, etc, etc.