Tracing rails and Apache

To try to track down the pesky and utterly uninformative "500 error" I get trying to run rails via plain CGI under apache, I decide just dive in and follow things along till I find where they blow up.

Where things are

The road to ruin

When I tell my browser to go to http://myhost/rails_work/demo/public/say/hello
we end up (via apache CGI) running /www/main/rails_work/demo/public/dispatch.cgi

This pulls in:

/www/main/rails_work/demo/config/environment.rb
/usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb
Ultimately it calls Dispatcher.dispatch
Everything seems OK up until the following line:
request, response = ActionController::CgiRequest.new(cgi, session_options), ActionController::CgiResponse.new(cgi)
prepare_application
ActionController::Routing::Routes.recognize!(request).process(request, response).out(output)
We can actually track this one step further to the recognize(request) method in:
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb
Here any attempt to use or print the variable request gives us our 500 error -- apparently it is undefined.

How should it ever have been defined? This certainly isn't obvious in any way from anything I have yet seen along the way.
Somehow, ruby is catching (and hiding!!) exceptions in some clever and very unfortunate way .....

Some ideas

Looking at /www/main/rails_work/demo/config/environment.rb shows there are some tricks available there to set ENV['RAILS_ENV'] as well as config.log_level which may be useful.

Also this requires the file: /www/main/rails_work/demo/config/boot.rb Which will end up running:

/usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/initializer.rb
However, we really want to look at:
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/cgi_process.rb

Feedback? Questions? Drop me a line!

Ruby on Rails notes / [email protected]