从命名空间到子域? [英] From Namespace to Subdomain?

查看:85
本文介绍了从命名空间到子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要做的是将名称空间路由与子域路由匹配,例如在我的route.rb中,我有:

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

但是我不喜欢这里的URL,我想将页面更改为:

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!!

推荐答案

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

类似问题

这篇关于从命名空间到子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆