I've discovered that application.rb is being loaded twice in a couple situations. It is not when simply running script/server, but it is when running script/console and specs with rspec.
The first place it is always loaded is in the #to_prepare callback in dispatcher.rb, using #require_dependency. The second time it's being loaded is simply using "require 'application'" in console_with_helpers:19, and in rspec_on_rails/lib/spec/rails.rb:3
I don't think it's expected behavior that requiring 'application' loads it a second time.
Looking at the code, it appears that #require_dependency (which calls #require_or_load) has two different mechanisms: :load or :require. I'm curious if anyone knows the reasoning for this, and why :load is the default. But even if it did use #require, #require_or_load expands the path of the filename, so simply requiring application would still re-load it.
I'm also wondering if #require_dependency is necessary in the dispatcher. Would simply using #require do the trick?
I'm willing to pursue a patch to fix this, I just wanted to see if anyone had any insights.
PGP.sig (186 Bytes)