make subdomain是否具有root用户名?

Rub*_*tic 3 subdomain router namespaces ruby-on-rails

是否可以将命名空间作为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
Run Code Online (Sandbox Code Playgroud)

Ric*_*dan 8

你可以在子域约束中使用命名空间,如果这就是你所要求的

constraints subdomain: 'm' do
  namespace :mobile do
    resources :home
    resources :profiles
  end
  resources :messages
  root :to => 'mobile/home#index'
end
Run Code Online (Sandbox Code Playgroud)

或者这里有这个答案:从命名空间到子域?主张这种方法:

constraints :subdomain => "mobile" do
  scope :module => "mobile", :as => "mobile" do
    resources :profiles
    resources :home
  end
end
Run Code Online (Sandbox Code Playgroud)