From Namespace to Subdomain?

两盒软妹~` 提交于 2019-12-04 19:41:48

问题


what I want to do is to match the namespace route to subdomain route, for example in my routes.rb I have:

namespace :group do
  resources :groups
  resources :clubs
end

The current path of group index and each group is like:

lvh.me/group/groups
lvh.me/group/groups/1

But I don't like the URL here, I want to change the pages to:

group.lvh.me/groups
group.lvh.me/groups/1

As there will be several similar namespaces, is there a easier way for this? Many thanks!!


回答1:


constraints :subdomain => "admin" do
  scope :module => "admin", :as => "admin" do
    resources :players
  end
end

Similar Issue




回答2:


constraints :subdomain => "group" do
 scope :module => "group", :as => "group" do
  resources :group
 end
end


来源:https://stackoverflow.com/questions/6367636/from-namespace-to-subdomain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!