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 `<main>'
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
···
On Thu, Feb 9, 2012 at 9:31 PM, Hasmukh Patel <tohasmukh@yahoo.com> wrote:
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 `<main>'