Skip to content

Instantly share code, notes, and snippets.

@jacklynrose
Created May 12, 2011 04:56
Show Gist options
  • Save jacklynrose/967948 to your computer and use it in GitHub Desktop.
Save jacklynrose/967948 to your computer and use it in GitHub Desktop.
Admin Controller + Subdomain Restriction + Whole URL Glob + Root Route for subdomains, no subdomain, and www subdomain
require 'Subdomain'
CMS::Application.routes.draw do
namespace "admin" do |admin|
resources :pages # Admin::PagesController Routes
end
constraints(Subdomain) do
match '/' => "pages#root" # Route for Root URL for Subdomains
match '*slug' => 'pages#show' # Route for Page URL for Subdomains
end
root :to => "pages#index" # Application Root Route
end
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