Rack 应用程序中的 Rails.root 等价物是什么? [英] What's the Rails.root equivalent in a Rack application?

查看:37
本文介绍了Rack 应用程序中的 Rails.root 等价物是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉 Rails 中的 Rails.root,它告诉您当前应用程序的目录.这有时非常方便.

I'm familiar with the Rails.root in Rails which tells you the directory of your current application. This is quite handy sometimes.

现在我正在开发一个 Rack 应用程序(Rails 基于它).如何找出 Rack 应用程序的 Rails.root 等效项?

Now I'm developing a Rack application (on which Rails is based). How do I find out the Rails.root equivalent for a Rack application?

谢谢.

推荐答案

这会以字符串形式返回根目录.

This returns the root directory in a string.

Rack::Directory.new('').root

不确定是否有更好、更短的语法.

Not sure if there's a better, shorter syntax.

这篇关于Rack 应用程序中的 Rails.root 等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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