loadee.rb
puts \'> This is the second file.\'
loaddemo.rb
puts \'This is the first (master) program file.\'
load \'loadee.rb
If you provide just a filename to require
, it will only look in the predefined $LOAD_PATH
directories. However, if you provide a path with your filename, it should work:
puts 'This is the first (master) program file.'
require './loadee.rb'
puts 'And back again to the first file.'
You could also add your project's folder to the load path instead:
$LOAD_PATH.unshift File.dirname(__FILE__)
puts 'This is the first (master) program file.'
require 'loadee.rb'
puts 'And back again to the first file.'
And last, you could just use require_relative
instead:
puts 'This is the first (master) program file.'
require_relative 'loadee.rb'
puts 'And back again to the first file.'