Undefined method error associated with a particular method
I've defined a method in a file called utility.rb
. I've tried to call the method inside another file called main.rb
. In main.rb
, I did require
that file by saying require utility
, but when I ran main.rb
开发者_高级运维, it gave me the undefined method error associated with that particular method. utility.rb
and main.rb
are in the same directory. Any idea?
I guess you have a file utility.rb
in any of your installed ruby libraries. This file is loaded instead of your one. Choose a more specific name for your file or add .
to the beginning of your lib search path:
$:.unshift('.')
精彩评论