0

The following way works perfectly

require "#{Rails.root}/lib/mymodule/class1.rb"

But why do do I have to put #{Rails.root}

  • You should instead tell Rails to autoload `lib`: http://stackoverflow.com/questions/3356742/best-way-to-load-module-class-from-lib-folder-in-rails-3 – user229044 Aug 08 '13 at 20:39

1 Answers1

1

As of Ruby 2.0, Ruby no longer considers the current directory to be in the require path. You could also use require ./lib/mymodule/class1.rb.

user229044
  • 232,980
  • 40
  • 330
  • 338