[Instantrails-users] Fwd: [Rails-commit] [3237] trunk/actionpack: More robust relative url root discovery for SCGI compatibility.

Curt Hibbs curt.hibbs at gmail.com
Thu Dec 8 07:01:33 EST 2005


Take a look at this change just committed to the Rails CVS repo... should
help us a lot!

Curt

---------- Forwarded message ----------
From: david at loudthinking.com <david at loudthinking.com>
Date: Dec 7, 2005 10:40 PM
Subject: [Rails-commit] [3237] trunk/actionpack: More robust relative url
root discovery for SCGI compatibility.
To: rails-commit at lists.rubyonrails.org

 Revision 3237 Author bitsweat Date 2005-12-08 04:40:24 +0000 (Thu, 08 Dec
2005) Log Message

More robust relative url root discovery for SCGI compatibility.  This
solves the 'SCGI routes problem' -- you no longer need to prefix all
your routes with the name of the SCGI mountpoint.  References #3070.

Modified Paths

   - trunk/actionpack/CHANGELOG<#10808aba4322d65a_trunkactionpackCHANGELOG>
   - trunk/actionpack/lib/action_controller/request.rb<#10808aba4322d65a_trunkactionpacklibaction_controllerrequestrb>
   - trunk/actionpack/test/controller/request_test.rb<#10808aba4322d65a_trunkactionpacktestcontrollerrequest_testrb>

 Diff Modified: trunk/actionpack/CHANGELOG (3236 => 3237)

--- trunk/actionpack/CHANGELOG	2005-12-08 04:36:22 UTC (rev 3236)
+++ trunk/actionpack/CHANGELOG	2005-12-08 04:40:24 UTC (rev 3237)
@@ -1,5 +1,7 @@
 *SVN*

+* More robust relative url root discovery for SCGI compatibility. 
This solves the 'SCGI routes problem' -- you no longer need to prefix
all your routes with the name of the SCGI mountpoint.  #3070 [Dave
Ringoen]
+
 * Fix docs for text_area_tag. #3083. [Christopher Cotton]

 * Change form_for and fields_for method signatures to take object
name and object as separate arguments rather than as a Hash. [DHH]

 Modified: trunk/actionpack/lib/action_controller/request.rb (3236 => 3237)

--- trunk/actionpack/lib/action_controller/request.rb	2005-12-08
04:36:22 UTC (rev 3236)
+++ trunk/actionpack/lib/action_controller/request.rb	2005-12-08
04:40:24 UTC (rev 3237)
@@ -169,7 +169,8 @@
     # 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' ?
File.dirname(env["SCRIPT_NAME"].to_s).gsub(/(^\.$|^\/$)/, '') : ''
+      @@relative_url_root ||= server_software == 'apache' ?
env["SCRIPT_NAME"].to_s.sub(/\/dispatch\.(fcgi|rb|cgi)$/, '') : ''
+
     end

     # Returns the port number of this request as an integer.

 Modified: trunk/actionpack/test/controller/request_test.rb (3236 => 3237)

--- trunk/actionpack/test/controller/request_test.rb	2005-12-08
04:36:22 UTC (rev 3236)
+++ trunk/actionpack/test/controller/request_test.rb	2005-12-08
04:40:24 UTC (rev 3237)
@@ -100,6 +100,11 @@
     @request.relative_url_root = nil
     @request.env['SCRIPT_NAME'] = "/collaboration/hieraki/dispatch.cgi"
     assert_equal "/collaboration/hieraki", @request.relative_url_root
+
+    # apache/scgi case
+    @request.relative_url_root = nil
+    @request.env['SCRIPT_NAME'] = "/collaboration/hieraki"
+    assert_equal "/collaboration/hieraki", @request.relative_url_root
   end

   def test_request_uri


_______________________________________________
Rails-commit mailing list
Rails-commit at lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-commit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/instantrails-users/attachments/20051208/a59c7aa7/attachment.htm


More information about the Instantrails-users mailing list