Send As SMS
Transcraft Blog
The choice of the IT professionals

Thursday, February 02, 2006

Rails Trac bug #3493 regarding broken fcgi under Apache

OK, the original posting regarding this bug report can be found here

I had to upgrade to Rails 1.0.0 finally because another project does not work under Rails 0.14.3, but I found that for some reason Rails 1.0.0 does not work with my fcgi enabled Apache server. The URL's generated for all the static resources like images and Javascript etc. are all prepended with the name of the damn fcgi script !

So I quickly checked back with Trac, guess what, nobody cares. Fine, I will fix it myself. Took me a couple of hours to finally track down the offending code which has changed for the worse in the new version. makes me really angry that somebody can actually check in some code that breaks things rather than make them better.

This is the original code, which works perfectly in the action controller 1.11.0:

def relative_url_root
@@relative_url_root ||= server_software == 'apache' ? File.dirname(env["SCRIPT_NAME"].to_s).gsub(/(^\.$|^\/$)/, '') : ''

So clearly the author makes special provision for Fcgi running on Apache, can does not make assumptions about the environment the code has to run in (this is why if you use WEBrick you will not encounter this problem).

This is the code as it is currently in action controller 1.11.2, the newer version in Rails 1.0:

# Returns the path minus the web server relative installation directory.
# This method returns nil unless the web server is apache.
def relative_url_root
#@@relative_url_root ||= server_software == 'apache' ? env["SCRIPT_NAME"].to_s.sub(/\/dispatch\.(fcgi|rb|cgi)$/, '') : ''

The author is basically you that you are stuffed if the fcgi script is not called dispatch.fcgi. Brilliant ! Highlights my point in other posts that if you customise your Rails installation in any way make sure it is not a walk in the park for unwanted visitors, ugly problems like this will come back and bite you hard .

posted by David at 1:52 AM

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home

Home
Contact us

Previous Posts

links to this post

Powered by Blogger