我目前收到错误:
No route matches [GET] "/tenant_admin"
我使用的是:
http://example.com/accounts/1/tenant_admin
但我现在将帐户ID 作为子域名传递;
http://AccountName.example.com/
是否可以使网址像这样工作:
http://AccountName.example.com/tenant_admin?
Routes.rb
get "log_out" => "sessions#destroy", :as => "log_out"
get "log_in" => "sessions#new", :as => "log_in"
get "sign_up" => "users#new", :as => "sign_up"
resources :users
resources :sessions
resources :password_resets
resources :accounts do
resources :tenant_admin
end
constraints(Subdomain) do
match '/' => 'accounts#show'
end
root :to => "welcome#index"
答案 0 :(得分:4)
您必须将租户路线置于resources :accounts
和constraints(Subdomain)
之下。我不建议使用复制和粘贴,而是使用lambda。
tenant_routes = lambda do
resources :tenant_admin
end
resources :accounts do
tenant_routes.call
end
constraints(Subdomain) do
tenant_routes.call
end