-
-
Save Irostovsky/1269749 to your computer and use it in GitHub Desktop.
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
When the constraints block is active, I get RoutingError: No route matches "/" when going to localhost:3000. If I comment the block out, it works just fine. But I need both: | |
http://example.com should render PagesController#show with params[:permalink] being 'index' | |
http://clemensk.example.com should render ProfilesController#show | |
Hints anyone? | |
Thanks! |
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
constraints(Subdomain) do | |
match '/', :to => 'profiles#show', :as => :profile # works! | |
end | |
match '/', :to => 'pages#show', :permalink => 'index' # shortcut root :to => 'pages#show' – either doesn't work |
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
# from railscasts.com | |
class Subdomain | |
def self.matches?(request) | |
i = Rails.env.development? ? 0 : 1 # so I can use localhost:3000 | |
request.subdomain(i).present? && request.subdomain(i) != "www" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment