[英]How to get mountable engine path in Rails 5?
I am writing a middleware inside a mountable engine, and I need to know the mount point of the engine.我正在一个可挂载的引擎中编写一个中间件,我需要知道引擎的挂载点。 How would i do this in Rails 5?
我将如何在 Rails 5 中做到这一点? I've tried
MyEng::Engine.routes._generate_prefix({})
but that does not work in Rails 5.我试过
MyEng::Engine.routes._generate_prefix({})
但这在 Rails 5 中不起作用。
If you want to get the path on which the engine is mounted you can use the following method:如果要获取引擎安装的路径,可以使用以下方法:
MyEng::Engine.routes.find_script_name({})
See comments for more details.有关更多详细信息,请参阅评论。
I think you are looking for this one: MyEngine::Engine.root
.我想你正在寻找这个:
MyEngine::Engine.root
。 See this question看到这个问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.