Skip to content

Instantly share code, notes, and snippets.

@jnicklas
Created November 18, 2009 23:07
  • Star 2 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jnicklas/643a758320a2926bd2ed to your computer and use it in GitHub Desktop.
# This will append the account name to all links and read it out as the account
# name in all tests.
class ApplicationController < ActionController::Base
def default_url_options(options=nil)
if Rails.env.test?
{ :account_name => current_account_name }
else
{}
end
end
def current_account_name
name = request.subdomains.first
name = params[:account_name] if Rails.env.test?
name
end
def current_account
Account.find_by_subdomain(current_account_name)
end
end
@esdras
Copy link

esdras commented Aug 28, 2010

Thanks man! This gist saved my day.

@sj26
Copy link

sj26 commented Mar 1, 2012

If you actually want to test the subdomains: https://gist.github.com/1939812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment