Created
May 7, 2013 16:02
-
-
Save welingtonsampaio/5533777 to your computer and use it in GitHub Desktop.
Method for create url with subdomain
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
def with_subdomain(subdomain) | |
subdomain = (subdomain || "").to_s | |
subdomain += "." unless subdomain.empty? | |
domain=request.domain.gsub! /^(\w){2}\./, "" | |
[subdomain, domain].join | |
end | |
def url_for(options = nil) | |
if options.kind_of?(Hash) && options.has_key?(:subdomain) | |
options[:host] = with_subdomain(options.delete(:subdomain)) | |
options[:port] = request.port_string.gsub(':','') unless request.port_string.empty? | |
end | |
super | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment