While calling module, throwing error

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>'

···

--
Posted via http://www.ruby-forum.com/.

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>'

--
*** Available for a new project ***

Peter Vandenabeele
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 Rex