Permalink
Browse files

Fix routing to handle :some_param => nil better

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2054 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
seckar committed Aug 26, 2005
1 parent 9aafcd9 commit 1cbd1f9698c686289003590557b44eaa1d918297
Showing with 11 additions and 3 deletions.
  1. +11 −3 actionpack/lib/action_controller/routing.rb
@@ -19,10 +19,14 @@ def controller_relative_to(controller, previous)
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 @@ def generate(options, request_or_recall_hash = {})
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)

0 comments on commit 1cbd1f9

Please sign in to comment.