Skip to content

Instantly share code, notes, and snippets.

@mikel
Created September 5, 2012 00:45
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 mikel/3628584 to your computer and use it in GitHub Desktop.
Save mikel/3628584 to your computer and use it in GitHub Desktop.
Subdomain Checker
Rails::Application.routes.draw do
# Limits the admin site only on the admin subdomain
constraints subdomain: /^admin/ do
ActiveAdmin.routes(self)
# Make resque only available to the admin users & redirect to admin login
# if trying to access resque without being logged in.
match('/admin/resque/admin/login' => redirect('/admin/login'))
authenticate :admin_user do
mount Resque::Server.new, :at => "/admin/resque"
end
devise_for :admin_users, ActiveAdmin::Devise.config
end
end
class SubdomainChecker
def self.matches?(request)
Rails.logger.info "SubdomainChecker: Subdomain: '#{request.subdomain}' Host: '#{request.host}'"
subdomain = request.subdomain
subdomain.to_s =~ /^((?!www)(?!app)(?!admin).)/
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment