I have a Rails 4.0 app with that allows users to access blogs through subdomains. My routes currently look like this:
match '', to: 'blogs#show', via: [:get, :post], constraints: lambda { |r| r.subdomain.present? && r.subdomain != 'www' }
resources :foobars
Now, when I navigate to somesubdomain.example.com
I am indeed taken to the show
action of the blogs
controller action, as expected.
When I navigate to example.com/foobars
I can access the index
action of the foobars
controller, as expected.
However, I only get a behavior I do not desire:
When I navigate to somesubdomain.example.com/foobars
, I can still access the the index
action of foobars
controller.
Is there a way to limit or exclude all resources that I do not specifically allow for a particular subdomain (i.e. somesubdomain.example.com/foobars
will not work unless otherwise specified).
Thanks!