[英]Rails engine path helper doesn't include mount namespace
I have created a rails engine which I'm mounting in the main application's routes.rb: 我创建了一个rails引擎,我将它安装在主应用程序的routes.rb中:
mount OsuAuth::Engine => '/admin'
I would like to reference a users path helper defined in the engine from my main application, for which I tried: 我想从我的主应用程序引用引擎中定义的用户路径助手,我尝试过:
<%= link_to 'Users', osu_auth.users_path %>
However this generates a path to /users
instead of the working path of /admin/users
. 但是,这会生成
/users
的路径,而不是/admin/users
的工作路径。
Running rake routes
also outputs the route without the /admin namespace: 运行
rake routes
还会输出不带/ admin命名空间的路由:
users GET /users(.:format) osu_auth/users#index
This seems odd to me. 这对我来说似乎很奇怪。 What happened to the /admin namespace where I mounted the engine?
我安装引擎的/ admin命名空间发生了什么变化? How can I get generate the correct path?
如何生成正确的路径?
Try to use namespace
directive: 尝试使用
namespace
指令:
namespace :admin do
mount OsuAuth::Engine
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.