Permalink
Browse files

Tiny little fix to make missing controller error messages much more i…

…nformative.

Case in point, before the fix, I was getting this error (Rails 2.3.5):

	no such file to load -- application.rb (MissingSourceFile)
	PhusionPassenger::UnknownError

After the fix, I now get this:

	Expected /Users/slippyd/Sites/tradechic.net/app/helpers/admin/sotws_helper.rb to define Admin::SotwsHelper
	LoadError

Fixes issue #439.
  • Loading branch information...
1 parent fd82697 commit 6fa2472fdc992f1f7477f5cbfde6e073b1a5eadf @capnslipp capnslipp committed with FooBarWidget Dec 12, 2009
Showing with 13 additions and 2 deletions.
  1. +13 −2 lib/phusion_passenger/railz/application_spawner.rb
@@ -307,10 +307,21 @@ def load_environment_with_passenger
if !defined?(Dispatcher)
require 'dispatcher'
end
+ # Rails 2.2+ uses application_controller.rb while older versions use application.rb.
begin
require_dependency 'application_controller'
- rescue LoadError
- require_dependency 'application'
+ rescue LoadError => e
+ begin
+ require_dependency 'application'
+ rescue LoadError
+ # Considering that most apps these das are written in Rails
+ # 2.2+, if application.rb cannot be loaded either then it
+ # probably just means that application_controller.rb threw
+ # a LoadError. So we raise the original error here; if the
+ # app is based on Rails < 2.2 then the error will make less
+ # sense but we can only choose one or the other.
+ raise e
+ end
end
# - No point in preloading the application sources if the garbage collector

0 comments on commit 6fa2472

Please sign in to comment.