在ruby中unshift + file.join [英] unshift + file.join in ruby

查看:328
本文介绍了在ruby中unshift + file.join的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

File.join(File.dirname(__ FILE __),\
'vendor','addressable-2.1.0','lib','$'可寻址的','uri')

上面的代码是否访问具有此路径的文件:

 'vendor / addressable-2.1.0 / lib / addressable / uri'
pre>

我试图将可寻址的gem放入Sinatra应用程序中以将其部署到我的托管服务提供商,但我一直在收到:

 no file to load  -  addressable / uri


$在 config.ru 中放置< unshift '行后,b $ b

。 $ b

解决方案

上面的代码在查找外部文件的全局变量中添加了vendor / addressable-2.1.0 / lib / addressable / uri 。路径将与放置此代码的文件的目录相关。因此,{dir}是config.ru所放置的目录,它将添加 {dir} /vendor/addressable-2.1 .0 / lib / addressable / uri 到include的查找路径。

$:.unshift File.join(File.dirname(__FILE__),\
'vendor','addressable-2.1.0','lib','addressable','uri')

Does the code above access a file that has this path:

'vendor/addressable-2.1.0/lib/addressable/uri'

I'm trying to vendor the addressable gem into a Sinatra app to deploy it to my hosting provider but I keep receiving:

"no such file to load -- addressable/uri"

after putting the 'unshift' line in config.ru.

解决方案

The above code adds the path "vendor/addressable-2.1.0/lib/addressable/uri" to the global variable used for looking up external files. The path will be relative to the directory that houses the file this code is placed in. So were {dir} is the directory config.ru is placed, it will add {dir}/vendor/addressable-2.1.0/lib/addressable/uri to the lookup path for includes.

这篇关于在ruby中unshift + file.join的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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