Terry Li
Terry Li

Reputation: 17268

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?

Upvotes: 1

Views: 1456

Answers (1)

undur_gongor
undur_gongor

Reputation: 15954

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('.')

Upvotes: 2

Related Questions