Rails:有 Engine.root 吗? [英] Rails: is there an Engine.root?

查看:51
本文介绍了Rails:有 Engine.root 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rails.root 返回指定 Rails 项目根目录的 Path 对象.

Rails.root returns a Path object specifying the root of a Rails project.

Rails 引擎有等价物吗?喜欢 Engine.root 吗?如果没有,我还能如何从 Rails 引擎的根目录建立路径?

Is there an equivilent for Rails engines? Like Engine.root? If not, how else could I build up a path from the root of my Rails engine?

推荐答案

假设你的引擎文件是这样设置的:

Lets say your engine file is set up like this:

module MyEngine
  class Engine < Rails::Engine
    #......
  end
end

您可以像这样在 Engine 类上调用 root:

You can call root on the Engine class like this:

MyEngine::Engine.root

这篇关于Rails:有 Engine.root 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆