500 Error running the dispatchers in Apache?


#1

I am running Rails 0.14.3 on a RedHat Linux server (at Rackspace if it
matters).

I have a completely vanilla installation of Rails set up, with one
controller and an index method that does nothing and a template that
just outputs “Hello!”. Nothing fancy.

When I load up WEBrick, I can hit the controller URL and it works fine.
I see my template, all is well.

When I hit the controller URL via Apache (1.3.27), I get a “Status: 500
Internal Server Error”. Nothing at all appears in the
log/development.log file either.

Now this is running on a virtual host, and I have confirmed that all my
suexec permissions are correct (in fact if I put a small “Hello World”
Ruby CGI in the folder, with all the same ownership and permissions, it
runs fine - I am fairly confident this isn’t the problem).

So I started tracing back through the Rails codebase from the
dispatch.cgi file, outputting some messages as I went, to figure out
where the script was actually failing. I inspected the cgi object that
is returned in the ‘dispatch’ method in dispatcher.rb in the actual
rails gem, and it looks like this:

#CGI:0x409fb4b0 @multipart=false,
@cookies={"__utma"=>[“11232945.1217992048.1134517517.1134517517.1134517517.1”],
“_session_id”=>[“598ed6bd708ed7ca716350153e277926”],
“__utmc”=>[“11232945”],
“__utmz”=>[“11232945.1134517517.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)”]},
@output_hidden=nil, @output_cookies=nil, @params={}

The request object looks like this:

#ActionController::CgiRequest:0x409fb4d8
@session_options={:session_path=>"/", :prefix=>“ruby_sess.”,
:database_manager=>CGI::Session::PStore}, @cgi=#<CGI:0x409fb4b0
@multipart=false,
@cookies={"__utma"=>[“11232945.1217992048.1134517517.1134517517.1134517517.1”],
“_session_id”=>[“598ed6bd708ed7ca716350153e277926”],
“__utmc”=>[“11232945”],
“__utmz”=>[“11232945.1134517517.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)”]},
@output_hidden=nil, @output_cookies=nil, @params={}

Now, where this actually falls apart is during the process that happens
a few lines lower, here:

ActionController::Routing::Routes.recognize!(request).process(request,
response).out(output)

I managed to figure out (I think) that the process command is being
executed on a returned object of type controller, in
actionpack/lib/controller/action_controller/base.rb

Within there I followed it to the “assign_shortcuts” method (which takes
the request and response objects as parameters) and it fails on the line

@response.session = request.session

If I put in output before that line, it works fine, if I put output
after that line, it doesn’t show up, so this seems to be where the
exception is being thrown?

I continued to dig into the session stuff a bit but that’s when I got
totally lost. My controller isn’t even starting up a session, unless
this happens automatically?

Any help would be greatly appreciated, I feel I’m so close to getting
this going, but I’m still new-ish to Ruby and to Rails as well…

Thanks alot,
Seb


#2

Seb Barre wrote:

totally lost. My controller isn’t even starting up a session, unless
this happens automatically?

Try deleting old sessions. On Unix, /tmp/ruby_sess*


We develop, watch us RoR, in numbers too big to ignore.