可安装的引擎安装在什么路径上 [英] What path is a mountable engine mounted on
本文介绍了可安装的引擎安装在什么路径上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从可安装引擎的布局内部了解它当前正在安装的路径。
I need to know, from inside of a layout of a mountable engine, what path it's currently being mounted on. What would be the way to do it?
例如我的routes.rb包含以下行:
E.g. my routes.rb contains the following line:
mount BackendCore::Engine => "/backend"
从BackendCore内部,我需要访问 / backend的值。
From inside of the BackendCore, I need the access to the value of "/backend".
推荐答案
更新:这可能仅适用于Rails 3!
UPDATE: this probably applies to Rails 3 only!
我找到了解决方案:
Rails.application.routes.named_routes[:backend_core].path #=> "/backend"
这篇关于可安装的引擎安装在什么路径上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文