0

I solved my problem through

require_relative
require './whateverfileiplannedtorequire'
load 'whateverfileiplannedtorequire'

but I am trying to get require to work without the ./ at the beginning as is advertised in the Beginning Ruby book. I hoped pushing my CWD into the $: array would fix this, but it didn't. How would I manage to get require to work as shown in the book?

4

1 回答 1

0

利用

$:.unshift "/my/directory"

例如将当前目录(源文件所在的位置)添加到加载路径:

$:.unshift File.expand_path(File.dirname(__FILE__))
于 2013-05-22T05:51:54.057 回答