Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix url_for options[:subdomain] to allow objects as values

* e.g. blog_url(subdomain: current_user) instead of blog_url(subdomain: current_user.to_param)
  • Loading branch information...
commit 5f67cfeda116f2b932ef72781420aa37e62437ca 1 parent a5589db
@choonkeat choonkeat authored
View
2  actionpack/lib/action_dispatch/http/url.rb
@@ -70,7 +70,7 @@ def host_or_subdomain_and_domain(options)
host = ""
unless options[:subdomain] == false
- host << (options[:subdomain] || extract_subdomain(options[:host], tld_length))
+ host << (options[:subdomain] || extract_subdomain(options[:host], tld_length)).to_param
host << "."
end
host << (options[:domain] || extract_domain(options[:host], tld_length))
View
8 actionpack/test/controller/url_for_test.rb
@@ -71,6 +71,14 @@ def test_subdomain_may_be_changed
)
end
+ def test_subdomain_may_be_object
+ model = mock(:to_param => 'api')
+ add_host!
+ assert_equal('http://api.basecamphq.com/c/a/i',
+ W.new.url_for(:subdomain => model, :controller => 'c', :action => 'a', :id => 'i')
+ )
+ end
+
def test_subdomain_may_be_removed
add_host!
assert_equal('http://basecamphq.com/c/a/i',
Please sign in to comment.
Something went wrong with that request. Please try again.