I currently have the following line in route.rb file
resources :pages, only: %i[index show create]
Moving forward I want my users to access pages#show
through a dedicated subdomain. So I've added the following line:
constraints subdomain: 'pages' do
get '/:id' => 'pages#show'
end
(I'm planning on keeping both routes for retro-compatibility)
Which allows users the access it through pages.mydevdomain.com/my-page-id When doing so in development environment I get the following message:
To allow requests to pages.mydevdomain.com, add the following to your environment configuration:
config.hosts << "pages.mydevdomain.com"
Which I've done and it works. However if I got to http://pages.mydevdomain.com
then I get to see the whole app I built which means that this subdomain isn't just for pages#show
like I wanted it.
My understanding of this constraint is that you can only access the pages#show action through the subdomain. But you are also allowing access using the
resources
method. So the constraint has no effect.You are not restricting access to any other controller. Maybe you want to wrap your routes like this: