Skip to content

Instantly share code, notes, and snippets.

@seangaffney
Created August 25, 2010 03:06
Show Gist options
  • Save seangaffney/548771 to your computer and use it in GitHub Desktop.
Save seangaffney/548771 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
before_filter do
if (Subdomain)
@site = Site.find_by_name!(request.subdomain)
end
end
end
# located in /lib and included via a require in /config/application.rb
# this code works when called elsewhere
class Subdomain
def self.matches?(request)
request.subdomain.present? && request.subdomain != "www"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment