mongrel --prefix does not properly notify rails 2.1.1

As of Rails 2.1.1, ActionController::AbstractRequest.relative_url_root no longer exists. It has been replaced by ActionController::Base.relative_url_root. This allows you to run your rails app in a virtual sub-directory of your webserver. The mongrel rails handler uses this method to set the relative url for your rails app. When working properly, mongrel_rails start --prefix /app would result in rails automatically generating URLs like http://somedomain/app/action.

Currently in mongrel 1.1.5 and Rails 2.1.1, if you wish to have this functionality you must set the relative_url_root by hand somewhere in your environment like so:
<pre> ActionController::Base.relative_url_root = "/app" if 'production' == ENV['RAILS_ENV'] </pre>

I have submitted a patch to mongrel, but if you can’t wait for the new release of mongrel, here is the patch:
<pre> Index: lib/mongrel/rails.rb =================================================================== --- lib/mongrel/rails.rb (revision 1036) +++ lib/mongrel/rails.rb (working copy) @@ -147,9 +147,15 @@ require env_location require 'dispatcher' require 'mongrel/rails' - - ActionController::AbstractRequest.relative_url_root = ops[:prefix] if ops[:prefix] - + + if ops[:prefix] + if ActionController::Base.respond_to?('relative_url_root=') + ActionController::Base.relative_url_root = ops[:prefix] # new way to set the relative URL in Rails 2.1.1 + else + ActionController::AbstractRequest.relative_url_root = ops[:prefix] + end + end + @rails_handler = RailsHandler.new(ops[:docroot], ops[:mime]) end

Posted by adevadeh 09 Oct 2008 at 07:52PM



>