diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2005-08-26 10:57:43 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2005-08-26 10:57:43 +0000 |
commit | 1cbd1f9698c686289003590557b44eaa1d918297 (patch) | |
tree | b3cf5f69a2412ac5dfbde6dfe5c6658d19d06887 | |
parent | 9aafcd92de48ff82ff0341bc3ae1fca2a50ab81a (diff) | |
download | rails-1cbd1f9698c686289003590557b44eaa1d918297.tar.gz rails-1cbd1f9698c686289003590557b44eaa1d918297.tar.bz2 rails-1cbd1f9698c686289003590557b44eaa1d918297.zip |
Fix routing to handle :some_param => nil better
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2054 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 8356b8ce55..74a0541d9e 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -19,10 +19,14 @@ module ActionController end end - def treat_hash(hash) + def treat_hash(hash, keys_to_delete = []) k = v = nil hash.each do |k, v| - hash[k] = (v.respond_to? :to_param) ? v.to_param.to_s : v.to_s if v + if v then hash[k] = (v.respond_to? :to_param) ? v.to_param.to_s : v.to_s + else + hash.delete k + keys_to_delete << k + end end hash end @@ -393,8 +397,12 @@ module ActionController options[:controller] = Routing.controller_relative_to(controller, recall_controller) end options = recall.dup if options.empty? # XXX move to url_rewriter? - Routing.treat_hash(options) # XXX Move inwards (to generated code) or inline? + + keys_to_delete = [] + Routing.treat_hash(options, keys_to_delete) + merged = recall.merge(options) + keys_to_delete.each {|key| merged.delete key} expire_on = Routing.expiry_hash(options, recall) generate_path(merged, options, expire_on) |