2013-03-25 49 views
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 

回答

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 
相關問題