diff options
author | Joshua Peek <josh@joshpeek.com> | 2010-03-09 21:20:13 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2010-03-09 21:20:13 -0600 |
commit | 1cc2a61ea655fea246f4c3e22a9e4a494e99d952 (patch) | |
tree | b1743dd232046ab122471e1595960d65ac991cb2 /actionpack/lib/action_dispatch | |
parent | 4d2470f7daad8cebd0a69f5ea0509a41af0596b8 (diff) | |
download | rails-1cc2a61ea655fea246f4c3e22a9e4a494e99d952.tar.gz rails-1cc2a61ea655fea246f4c3e22a9e4a494e99d952.tar.bz2 rails-1cc2a61ea655fea246f4c3e22a9e4a494e99d952.zip |
Allow default_url_options to be set on route set
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index ae4470d033..0b7b09ee7a 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -180,6 +180,11 @@ module ActionDispatch @set.add_route(*mapping) self end + + def default_url_options=(options) + @set.default_url_options = options + end + alias_method :default_url_options, :default_url_options= end module HttpHelpers diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 2b9fc9e0de..26f37161a7 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -186,6 +186,7 @@ module ActionDispatch attr_accessor :routes, :named_routes attr_accessor :disable_clear_and_finalize, :resources_path_names + attr_accessor :default_url_options def self.default_resources_path_names { :new => 'new', :edit => 'edit' } @@ -196,6 +197,7 @@ module ActionDispatch self.named_routes = NamedRouteCollection.new self.resources_path_names = self.class.default_resources_path_names.dup self.controller_namespaces = Set.new + self.default_url_options = {} @disable_clear_and_finalize = false clear! @@ -404,6 +406,8 @@ module ActionDispatch RESERVED_OPTIONS = [:anchor, :params, :only_path, :host, :protocol, :port, :trailing_slash, :skip_relative_url_root] def url_for(options) + options = default_url_options.merge(options || {}) + handle_positional_args(options) rewritten_url = "" |