Skip to content

Instantly share code, notes, and snippets.

@notrab
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save notrab/11326989 to your computer and use it in GitHub Desktop.

Select an option

Save notrab/11326989 to your computer and use it in GitHub Desktop.
# lib/account_detector.rb
class AcountDetector
def initialize(app)
@app = app
end
def call(env)
account = Club.find_by custom_domain: env["HTTP_HOST"]
if account
env["HTTP_HOST"] = "#{account.subdomain}.lvh.me:9292"
end
@app.call(env)
end
end
#environment.rb
config.middleware.use AccountDetector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment