Created
November 21, 2008 00:40
-
-
Save benschwarz/27292 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Extend the Request class to give | |
# a useful method to be able to route | |
# to subdomains | |
module Merb | |
class Request | |
def subdomain | |
return nil if subdomains.first == "www" | |
return subdomains.first | |
end | |
end | |
end | |
Merb::Router.prepare do |r| | |
match(:subdomain => /(.+)/).to(:username => ":subdomain[1]") do | |
# Everything within this block is sent :username => "mysubdomain" | |
resources :posts | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment