diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-03-04 17:43:46 -0800 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-03-04 17:43:46 -0800 |
commit | 900a2d304a83bad7a3958464b8dfa6fb49670686 (patch) | |
tree | 0890d17f239ac85509ed74a93b76c6409a7b1f38 /actionpack/lib/action_dispatch/routing | |
parent | 3438373f038cefda664b879f49eec8aec6a15a76 (diff) | |
download | rails-900a2d304a83bad7a3958464b8dfa6fb49670686.tar.gz rails-900a2d304a83bad7a3958464b8dfa6fb49670686.tar.bz2 rails-900a2d304a83bad7a3958464b8dfa6fb49670686.zip |
Get rid of relative_url_path in favor of respecting SCRIPT_NAME. Also added a way to specify a default SCRIPT_NAME when generating URLs out of the context of a request.
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/url_for.rb | 6 |
2 files changed, 9 insertions, 2 deletions
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) |