Skip to content

Instantly share code, notes, and snippets.

@clemens
Created November 18, 2010 22:35
Show Gist options
  • Save clemens/705804 to your computer and use it in GitHub Desktop.
Save clemens/705804 to your computer and use it in GitHub Desktop.
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!
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
# 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
@adamrubin
Copy link

I just ran into this same problem. Did you ever figure out how to make routing-filter respect constraints?

@clemens
Copy link
Author

clemens commented Dec 7, 2010

I've put the problem on hold because I had other things to do. I'll probably send a patch if the problem really is in routing filter or post an alternative solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment