Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Created June 20, 2010 20:52
Show Gist options
  • Save bcardarella/446092 to your computer and use it in GitHub Desktop.
Save bcardarella/446092 to your computer and use it in GitHub Desktop.
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