ruby - Cannot Load Module with Require -
i have module (cgi_helper.rb), cgi calls module, , html template. following error:
/system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in
require': cannot load such file -- cgi_helper (loaderror) >/system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:inrequire' lab4.cgi:8:in `'
the module: http://pastebin.com/yfj0rc8p
the cgi: http://pastebin.com/xs5liv2a
i can't figure out why can't find module. it's executable , in same dir cgi. here erb template.
<table> <tr> <th>number</th> <th>username</th> <th>passwd</th> <th>uid</th> <th>gid</th> <th>home dir</th> <th>shell</th> <% students.each |x| %> <% next if eachname[x].nil? %> <% s = student.new(eachname[x].split(':')) %> <tr> <% columns.each |c| %> <td><%= s.send(c).to_s %></td> <% end %> </tr> <% end %> </table> <% finish = time.now %> <h2> total elapsed time:<%= (finish.to_f - start.to_f).to_s %></h2>
you should change
require 'cgi_helper' to
require file.expand_path(file.dirname(__file__) + '/cgi_helper') or put unshift on top of script
$:.unshift file.dirname(__file__) require 'erb' require 'cgi_helper' include cgihelper detailed info require.
Comments
Post a Comment