3

是否有可能让命名空间成为 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
4

1 回答 1

8

如果这是您所要求的,您可以将命名空间置于子域约束内

constraints subdomain: 'm' do
  namespace :mobile do
    resources :home
    resources :profiles
  end
  resources :messages
  root :to => 'mobile/home#index'
end

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

constraints :subdomain => "mobile" do
  scope :module => "mobile", :as => "mobile" do
    resources :profiles
    resources :home
  end
end
于 2013-03-25T21:28:05.810 回答