Skip to content

Instantly share code, notes, and snippets.

@mikepack
Created September 16, 2011 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikepack/1222505 to your computer and use it in GitHub Desktop.
Save mikepack/1222505 to your computer and use it in GitHub Desktop.
Subdoamin Helper
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