Skip to content

Instantly share code, notes, and snippets.

@alanowens
Created September 17, 2012 19:19
Show Gist options
  • Save alanowens/3739223 to your computer and use it in GitHub Desktop.
Save alanowens/3739223 to your computer and use it in GitHub Desktop.
How to turn this into routes.rb entries
def subdomain_junk
if request.subdomain == 'signup'
unless ((request.path == new_user_registration_path) || (request.path == '/accounts/check_exists') || (request.path == '/users'))
redirect_to new_user_registration_path
end
elsif request.path == new_user_registration_path
unless ((request.subdomain == 'signup') || (request.path == '/accounts/check_exists'))
if request.port == 80
redir_url = request.protocol + 'signup' + '.' + request.domain + new_user_registration_path
else
redir_url = request.protocol + 'signup' + '.' + request.domain + ":" + request.port.to_s() + new_user_registration_path
end
redirect_to redir_url
end
else
if request.port == 80
redir_url = request.protocol + 'www' + '.' + request.domain + home_index_path
else
redir_url = request.protocol + 'www' + '.' + request.domain + ":" + request.port.to_s() + home_index_path
end
unless Account.exists?(:subdomain => request.subdomain)
unless request.url == redir_url
redirect_to redir_url
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment