diff options
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_controller/url_rewriter.rb | 24 |
2 files changed, 12 insertions, 22 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 82b12f3a7b..8356b8ce55 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -397,13 +397,7 @@ module ActionController merged = recall.merge(options) expire_on = Routing.expiry_hash(options, recall) - path, keys = generate_path(merged, options, expire_on) - - # Factor out? - extras = {} - k = nil - keys.each {|k| extras[k] = options[k]} - [path, extras] + generate_path(merged, options, expire_on) end def generate_path(merged, options, expire_on) @@ -590,7 +584,7 @@ module ActionController end def extra_keys(options, recall = {}) - generate(options.dup, recall).last.keys + generate(options.dup, recall).last end end diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb index 8ae6f3e57b..546bd13eb7 100644 --- a/actionpack/lib/action_controller/url_rewriter.rb +++ b/actionpack/lib/action_controller/url_rewriter.rb @@ -31,31 +31,27 @@ module ActionController rewritten_url end - def rewrite_path(options) - options = options.symbolize_keys - options.update((options[:params] || {}).symbolize_keys) + def rewrite_path(original_options) + options = original_options.symbolize_keys + options.update(params.symbolize_keys) if (params = options[:params]) RESERVED_OPTIONS.each {|k| options.delete k} - path, extras = Routing::Routes.generate(options, @request) + path, extra_keys = Routing::Routes.generate(options, @request) # Warning: Routes will mutate and violate the options hash - if extras[:overwrite_params] - params_copy = @request.parameters.reject { |k,v| %w(controller action).include? k } - params_copy.update extras[:overwrite_params] - extras.delete(:overwrite_params) - extras.update(params_copy) - end - - path << build_query_string(extras) unless extras.empty? + path << build_query_string(original_options.symbolize_keys, extra_keys) unless extra_keys.empty? path end # Returns a query string with escaped keys and values from the passed hash. If the passed hash contains an "id" it'll # be added as a path element instead of a regular parameter pair. - def build_query_string(hash) + def build_query_string(hash, only_keys = nil) elements = [] query_string = "" + + only_keys ||= hash.keys - hash.each do |key, value| + only_keys.each do |key| + value = hash[key] key = CGI.escape key.to_s key << '[]' if value.class == Array value = [ value ] unless value.class == Array |