Why am I unable to load my file in Ruby?
Edited for clarity
From
puts $LOAD_PATH
I am able to see my load paths. I do
$LOAD_PATH << 'C:/rubyfiles'
to add ruby files to my search path. I then put some r开发者_如何学Pythonandom custom rb file in there and do
require 'ya'
LoadError - No such file to load
What am I doing wrong?
Try doing
puts "$LOAD_PATH is #{$LOAD_PATH.inspect}"
puts "Files in rubyfiles is #{Dir.entries('C:/rubyfiles').inspect}"
and add the output of that debugging to the question.
When you want to load the file name with xxx.rb, you have load xxx.rb, not load xxx. This is one difference from require. Are you clear with that?
Guess I trusted too much in someone elses code which had an error. Still somewhat new with ruby thus I mistook the loaderror for issues with the main file without bothering to look in the code itself. Thanks anyways.
You can put your custom .rb files in lib/ folder inside your rails project
p/s: assuming it's a rails project
加载中,请稍侯......
精彩评论