Reputation: 1638
I googled it, but no luck
I have a file called mdl.rb and main.rb
, they both in the same folder
mdl.rb
has module Test_module
and method in it called say_hello
, I want to use that method in my main.rb
.
So my main.rb
looks like this:
require 'mdl'
say_hello
but I get error:
in `require': cannot load such file -- mdl (LoadError)
Upvotes: 0
Views: 76
Reputation: 59273
You would use
require_relative 'mdl.rb'
See Ruby docs for require_relative
.
(require_relative 'mdl'
and require './mdl'
also work, as pointed out in the comments by @MichaelBerkowski and @FélixSaparelli respectively.)
Upvotes: 1