私のルートがrails guideで説明されているもので機能しないのはなぜだろうか。ではなくhttp://admin.foo.dev:3000/
に連れて行ってくれます。root_path
admin::pages#home
ただし、最初のアプローチは機能します。Railscastから取得したものです。
# WORKS!
match '', to: 'pages#home', constraints: lambda { |r| r.subdomain.present? && r.subdomain != 'www' }
# does NOT work!
namespace :admin do
constraints :subdomain => "admin" do
root :to => 'pages#home'
end
end
ですべてをセットアップしました/etc/hosts
。次のようになります。
127.0.0.1 localhost
127.0.0.1 api.foo.dev admin.foo.dev foo.dev www.foo.dev