铁路路线:具有约束的控制器名称空间(子域) [英] Rail Routes: Controller namespaces with constraints (subdomains)

查看:82
本文介绍了铁路路线:具有约束的控制器名称空间(子域)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目的是创建一个子域来容纳所有管理功能(CRUD),并且该子域的名称为 admin 。负责的控制器集也组织在 admin 命名空间下,即,这些控制器位于 app / controllers / admin目录下。

The intention is to create a subdomain to hold all the administrative function (CRUD) and the name of the subdomain is "admin". The set of controllers responsible are also organized under the namespace of "admin", i.e. the controllers are under the app/controllers/admin directory.

理想情况下,以下路线应为

Ideally, the following routes should be

admin.mydomain.com/products/     
admin.mydomain.com/products/new ...

不是

admin.mydomain.com/admin/products/
admin.mydomain.com/admin/products/new ...

我想为助手提供 admin前缀,例如:

I would like to keep the helpers with the "admin" prefix such as:

new_admin_product
edit_admin_product






我当前的路由代码有效,如下所示:


My current routing code works and it is as below:

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

这是正确的方法吗?

推荐答案

是的,这将以您所知道的最简洁的方式为您提供精确的搜索结果

Yes, this will give you precisely what you're after in the neatest fashion I know possible.

这篇关于铁路路线:具有约束的控制器名称空间(子域)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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