diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-02-25 15:05:10 -0800 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-02-25 17:53:01 -0800 |
commit | 36fd9efb5e4bfc9ac3acd4189d4dc457dea8102a (patch) | |
tree | ee50b242b16d4d4a5c98a2d48f5b0af2d46e5ce0 /actionpack/lib/action_controller/url_rewriter.rb | |
parent | 9a5be2e5a80ab9e74294f32cfef58fbbcd9b637c (diff) | |
download | rails-36fd9efb5e4bfc9ac3acd4189d4dc457dea8102a.tar.gz rails-36fd9efb5e4bfc9ac3acd4189d4dc457dea8102a.tar.bz2 rails-36fd9efb5e4bfc9ac3acd4189d4dc457dea8102a.zip |
Continued effort to deglobalize the router
Diffstat (limited to 'actionpack/lib/action_controller/url_rewriter.rb')
-rw-r--r-- | actionpack/lib/action_controller/url_rewriter.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb index 272465d4f5..807b21cd0e 100644 --- a/actionpack/lib/action_controller/url_rewriter.rb +++ b/actionpack/lib/action_controller/url_rewriter.rb @@ -26,8 +26,14 @@ module ActionController # ROUTES TODO: Class method code smell def self.rewrite(router, options, path_segments=nil) + handle_positional_args(options) + rewritten_url = "" + # ROUTES TODO: Fix the tests + segments = options.delete(:_path_segments) + path_segments = path_segments ? path_segments.merge(segments || {}) : segments + unless options[:only_path] rewritten_url << (options[:protocol] || "http") rewritten_url << "://" unless rewritten_url.match("://") @@ -52,6 +58,21 @@ module ActionController protected + def self.handle_positional_args(options) + return unless args = options.delete(:_positional_args) + + keys = options.delete(:_positional_keys) + keys -= options.keys if args.size < keys.size - 1 # take format into account + + args = args.zip(keys).inject({}) do |h, (v, k)| + h[k] = v + h + end + + # Tell url_for to skip default_url_options + options.merge!(args) + end + def self.rewrite_authentication(options) if options[:user] && options[:password] "#{Rack::Utils.escape(options.delete(:user))}:#{Rack::Utils.escape(options.delete(:password))}@" |