How to use modules in Ruby -


i have script want call modules from. want modules reside in modules folder. main script has following line

require "modules/01httpserver" 

my 01httpserver modules in file named "01httpserver.rb" , it's in modules folder. file contains following code.

module 01httpserver     def self.helloworld(name)         puts "hello, #{name}"     end end 

so when run main script , trieds load module file, following error message: "`require': cannot load such file -- modules/01httpserver (loaderror)"

what causing this?

use require_relative. like:

require_relative "modules/01httpserver" 

http://extensions.rubyforge.org/rdoc/classes/kernel.html


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -