Created
May 12, 2011 04:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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