Created
June 20, 2010 20:52
-
-
Save bcardarella/446092 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
private | |
# To write subdomains on the url helpers: | |
# root_url(nil, {:subdomain => "subdomain"}) | |
def url_for(options = nil) | |
case options | |
when Hash | |
if subdomain = options.delete(:subdomain) | |
if request.subdomain.empty? | |
options[:host] = "#{subdomain}.#{request.host_with_port}" | |
else | |
options[:host] = request.host_with_port.sub(request.subdomain, subdomain) | |
end | |
end | |
end | |
super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment