I'm getting this error when trying to use include MyModule "Uninitialized constant"
Here is my implementation:
a.rb
class A
include MyModule
puts ARRAY
end
my_module.rb
module MyModule
ARRAY = [1,2,3]
end
CodePudding user response:
Ruby doesn't know about MyModule
because it doesn't read my_module.rb
Add at the top of a.rb
require_relative 'my_module'
if these files are in the same folder (or correct path to the file if not)