ruby-on-rails - 如何在命名空间内使用普通资源?
问题描述
我的控制器
account
-profiles_controller.rb
我的观点
account
-profiles
--index.html.haml
我的路线
namespace :account do
resources :profiles
end
目前以这个网址的形式工作。 http://localhost:3000/account/profiles
但我希望它是这样的。 http://localhost:3000/profiles
我该怎么做?
解决方案
使用scope
代替namespace
scope module: "account" do
resources :profiles
end
或者
你也可以写成
resources :profiles, module: "account"
有关详细信息,请参阅控制器命名空间和路由
推荐阅读
- javascript - 如何使用 jquery 更改输入中的值?
- kubernetes - 通过 kubectl 任务创建 ConfigMap
- matlab - 如何在线加速MATLAB?
- markdown - 图片未显示在 Github 托管的 Jekyll 博客上
- javascript - 如何检查 React 构建文件夹
- android - Android Scoped Stoage - 在 onActivityResult 中获取视频详细信息
- snmp - 如何在 SNMP MIB 中创建表
- c - 如何将指针数组初始化为NULL?
- hpc - 有没有办法在完成后制作 slurm 打印作业摘要?
- java - 如果选中前一个复选框(首先禁用其他复选框),如何在回收站视图中启用其他复选框?