aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/url_for.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-07-15 01:18:02 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-03 22:59:07 +0200
commite9791bec823e42372eca095b946c93c1712a0613 (patch)
tree8dc4f12b6c4646bdce775b58a8eca5721317b4d4 /actionpack/lib/action_dispatch/routing/url_for.rb
parent229a868264a1dd5f4441f4b82ccf2a51cf83511d (diff)
downloadrails-e9791bec823e42372eca095b946c93c1712a0613.tar.gz
rails-e9791bec823e42372eca095b946c93c1712a0613.tar.bz2
rails-e9791bec823e42372eca095b946c93c1712a0613.zip
Routes refactoring:
* added more tests for prefix generation * fixed bug with generating host for both prefix and url * refactored url_for method * organized tests for prefix generation
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/url_for.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/url_for.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb
index edcb7f9cbe..30b456f3df 100644
--- a/actionpack/lib/action_dispatch/routing/url_for.rb
+++ b/actionpack/lib/action_dispatch/routing/url_for.rb
@@ -123,19 +123,17 @@ module ActionDispatch
# url_for :controller => 'tasks', :action => 'testing', :host=>'somehost.org', :anchor => 'ok', :only_path => true # => '/tasks/testing#ok'
# url_for :controller => 'tasks', :action => 'testing', :trailing_slash=>true # => 'http://somehost.org/tasks/testing/'
# url_for :controller => 'tasks', :action => 'testing', :host=>'somehost.org', :number => '33' # => 'http://somehost.org/tasks/testing?number=33'
- def url_for(*args)
- if args.first.respond_to?(:routes)
- app = args.shift
- _with_routes(app.routes) do
+ def url_for(options = nil, *args)
+ if options.respond_to?(:routes)
+ _with_routes(options.routes) do
if args.first.is_a? Symbol
named_route = args.shift
- url_for _routes.url_helpers.__send__("hash_for_#{named_route}", *args)
+ url_for _routes.url_helpers.send("hash_for_#{named_route}", *args)
else
url_for(*args)
end
end
else
- options = args.first
case options
when String
options