Created
September 16, 2011 16:38
-
-
Save mikepack/1222505 to your computer and use it in GitHub Desktop.
Subdoamin Helper
This file contains 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
module UrlHelper | |
def with_subdomain(subdomain) | |
subdomain = (subdomain || "") | |
subdomain += "." unless subdomain.empty? | |
[subdomain, request.domain, request.port_string].join | |
end | |
def url_for(options = nil) | |
if options.kind_of?(Hash) && options.has_key?(:subdomain) | |
options[:host] = with_subdomain(options.delete(:subdomain)) | |
end | |
super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment