开发者

Ruby module include not loading dependent files

开发者 https://www.devze.com 2023-03-15 00:05 出处:网络
I have the following structure: lib/models/module_name.rb lib/models/module_name/one.rb lib/models/module_name/two开发者_如何学JAVA.rb

I have the following structure:

lib/models/module_name.rb
lib/models/module_name/one.rb
lib/models/module_name/two开发者_如何学JAVA.rb
lib/models/module_name/three.rb

module_name.rb contains the following:

require 'module_name/one'
require 'module_name/two'
require 'module_name/three'

When module_name.rb is loaded I get the error 'No such file to load -- module_name/one (LoadError)'

any ideas? Please excuse my ignorance.


Try using:

require File.dirname(__FILE__) + '/module_name/one'
require File.dirname(__FILE__) + '/module_name/two'
require File.dirname(__FILE__) + '/module_name/three'


Looks like the problem was caused by a problem with virtualbox and windows mounting interaction. Basically the files were moved after I performed a move, but the files were not correctly registered in the linux VM and thus could not be loaded by ruby.

0

精彩评论

暂无评论...
验证码 换一张
取 消