Skip to content

Instantly share code, notes, and snippets.

@kinopyo
Last active December 14, 2015 12:48
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 kinopyo/5088737 to your computer and use it in GitHub Desktop.
Save kinopyo/5088737 to your computer and use it in GitHub Desktop.
Notes: how to setup user based subdomain, http://stackoverflow.com/a/7265381/219065
module AppName
class UserSubdomainConstraint
def self.matches?( request )
request.subdomain.present? && request.subdomain != 'www'
end
end
end
AppName::Application.routes.draw do
devise_for :users
constraints(AppName::UserSubdomainConstraint) do
# THESE ARE THE ROUTES FOR USERS' SUBDOMAINS
end
end
def index
@user_account = User.where(:subdomain => request.subdomain).account
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment