是否可以将命名空间作为rails 3中子域的根?
目前我的路线是:
namespace :mobile do
resources :home
resources :profiles
root :to => "/mobile/home#index"
end
constraints subdomain: 'm' do
root :to => 'mobile/home#index'
resources :home
resources :profile
resources :messages
root :to => 'mobile/home#index'
end
答案 0 :(得分:8)
你可以在子域约束中使用命名空间,如果这就是你所要求的
constraints subdomain: 'm' do
namespace :mobile do
resources :home
resources :profiles
end
resources :messages
root :to => 'mobile/home#index'
end
或者这里有这个答案:From Namespace to Subdomain?提倡这种方法:
constraints :subdomain => "mobile" do
scope :module => "mobile", :as => "mobile" do
resources :profiles
resources :home
end
end