I have a folder full of ruby files, and when I try and require one file in another that is in the same directory using require 'file'
I get a LoadError
but when I use require './file'
everything works fine. Can somebody explain to me why this happens and if there is any way I can require a file without adding a ./
onto the file?
(Picture of directory):
If you want to require
a file not from the system $LOAD_PATH
but rather relative to the directory of the file you are require
ing from, you should use require_relative
. (Which, as you can see, isn't exactly extensively documented.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With