Mymodule.rb
module Mymodule
def Mymodule.mymessage
puts “You have four weeks in a month”
end
end
callingclass.rb
#!/user/bin/ruby
require “Mymodule”
include Mymodule
Mymodule.mymessage
Throwing following error
C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot loa d such file -- Mymodule (LoadError) from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in
require
’
from callingclass.rb:3:in `’
On Thu, Feb 9, 2012 at 9:31 PM, Hasmukh P. [email protected]
wrote:
from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in
require ' from callingclass.rb:3:in
’
Has to do with $LOAD_PATH (alias $: ) from which
‘.’ was removed from it in Ruby 1.9.x
You will find many explanations searching for (“ruby load_path 1.9”)
The first one is already relevant:
HTH,
Peter
–
*** Available for a new project ***
Peter V.
http://twitter.com/peter_v
http://rails.vandenabeele.com
http://coderwall.com/peter_v
In short: from 1.9.2 on, you have to use require_relative instead of
require for local files.
– Matma R.