简体   繁体   中英

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? I've tried MyEng::Engine.routes._generate_prefix({}) but that does not work in Rails 5.

Update after EL Rayle comment

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.

[previous wrong answer]

I think you are looking for this one: MyEngine::Engine.root . See this question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM