aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/url_for.rb2
-rw-r--r--actionpack/lib/action_controller/railtie.rb6
-rw-r--r--actionpack/lib/action_controller/url_rewriter.rb2
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb5
-rw-r--r--actionpack/lib/action_dispatch/routing/url_for.rb6
-rw-r--r--actionpack/test/controller/url_for_test.rb4
6 files changed, 19 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb
index c890dc51d4..89ab0b4753 100644
--- a/actionpack/lib/action_controller/metal/url_for.rb
+++ b/actionpack/lib/action_controller/metal/url_for.rb
@@ -12,7 +12,7 @@ module ActionController
# ROUTES TODO: relative_url_root should be middleware
# and the generator should take SCRIPT_NAME into
# consideration
- :relative_url_root => config.relative_url_root,
+ :script_name => request.env["SCRIPT_NAME"],
:_path_segments => request.symbolized_path_parameters
)
end
diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb
index e9edf80451..e638be5251 100644
--- a/actionpack/lib/action_controller/railtie.rb
+++ b/actionpack/lib/action_controller/railtie.rb
@@ -51,6 +51,12 @@ module ActionController
ac.stylesheets_dir = paths.public.stylesheets.to_a.first
ac.secret = app.config.cookie_secret
+ if ac.relative_url_root
+ ActiveSupport::Deprecation.warn "config.action_controller.relative_url_root " \
+ "is no longer effective. Please set it in the router as " \
+ "routes.draw(:script_name => #{ac.relative_url_root.inspect})"
+ end
+
ActionController::Base.config.replace(ac)
end
diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb
index 973a6facd7..8821892b3a 100644
--- a/actionpack/lib/action_controller/url_rewriter.rb
+++ b/actionpack/lib/action_controller/url_rewriter.rb
@@ -32,7 +32,7 @@ module ActionController
# ROUTES TODO: Fix the tests
segments = options.delete(:_path_segments)
- relative_url_root = options.delete(:relative_url_root).to_s
+ relative_url_root = options.delete(:script_name).to_s
path_segments = path_segments ? path_segments.merge(segments || {}) : segments
unless options[:only_path]
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 99436e3cb0..9ca1857966 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -211,6 +211,7 @@ module ActionDispatch
attr_accessor :routes, :named_routes
attr_accessor :disable_clear_and_finalize, :resources_path_names
+ attr_accessor :script_name
def self.default_resources_path_names
{ :new => 'new', :edit => 'edit' }
@@ -225,9 +226,11 @@ module ActionDispatch
@disable_clear_and_finalize = false
end
- def draw(&block)
+ def draw(options = {}, &block)
clear! unless @disable_clear_and_finalize
+ @script_name = options[:script_name]
+
mapper = Mapper.new(self)
if block.arity == 1
mapper.instance_exec(DeprecatedMapper.new(self), &block)
diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb
index 7f2c9a5c12..afbb2ecf16 100644
--- a/actionpack/lib/action_dispatch/routing/url_for.rb
+++ b/actionpack/lib/action_dispatch/routing/url_for.rb
@@ -101,7 +101,11 @@ module ActionDispatch
# end
def url_options
- self.class.default_url_options.merge(@url_options || {})
+ @url_options ||= begin
+ opts = self.class.default_url_options
+ opts.merge(:script_name => _router.script_name) if respond_to?(:_router)
+ opts
+ end
end
def url_options=(options)
diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb
index 07809aa480..fc7773dffe 100644
--- a/actionpack/test/controller/url_for_test.rb
+++ b/actionpack/test/controller/url_for_test.rb
@@ -118,7 +118,7 @@ module AbstractController
add_host!
assert_equal('https://www.basecamphq.com/subdir/c/a/i',
- W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https', :relative_url_root => '/subdir')
+ W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https', :script_name => '/subdir')
)
end
@@ -153,7 +153,7 @@ module AbstractController
controller = kls.new
assert_equal 'http://www.basecamphq.com/subdir/home/sweet/home/again',
- controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again', :relative_url_root => "/subdir")
+ controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again', :script_name => "/subdir")
end
end