Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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