I''m working on porting a dynamic website done in PHP over to mod_ruby. I have everything set up and working nicely (I can make a .rhtml page, put ruby code between <% %> and it works etc), but when I try to use "Eruby.import" as a sort of analog to PHP''s "require_once()", I run into trouble. 1) eruby is in my cgi-bin 2) here''s a sample of what I''m trying to do in PHP: require_once(''somedirectory/somefile.php''); 3) here''s a sample of what I''m trying to do in Ruby (as far as I can tell): require "eruby" Eruby.import "/var/www/html/somedirectory/somefile.rhtml" 4) here''s the error as reported in apache''s error_log: [Fri Jun 30 02:39:47 2006] [error] mod_ruby: error in ruby [Fri Jun 30 02:39:47 2006] [error] mod_ruby: /var/www/html/ruby/index.rhtml:12: uninitialized constant #<Module:0xb7a76530>::Eruby (NameError) [Fri Jun 30 02:39:47 2006] [error] mod_ruby: from (eval):0 [Fri Jun 30 02:39:47 2006] [error] mod_ruby: from /usr/lib/ruby/1.8/apache/eruby-run.rb:116:in `run'' [Fri Jun 30 02:39:47 2006] [error] mod_ruby: from /usr/lib/ruby/1.8/apache/eruby-run.rb:72:in `handler'' 5) here''s the error I get when I test it in irb (from this, I gather it probably isn''t a problem with apache''s settings): irb(main):001:0> require "eruby" => true irb(main):002:0> Eruby.import "/var/www/html/somedirectory/somefile.rhtml" NameError: uninitialized constant Eruby from (irb):2 from :0 6) here''s the relavent section in my httpd.conf: LoadModule ruby_module /usr/lib/httpd/modules/mod_ruby.so # ClearModuleList # AddModule mod_ruby.c <IfModule mod_ruby.c> RubyRequire apache/ruby-run # Execute *.rbx files as Ruby scripts <Files *.rbx> SetHandler ruby-object RubyHandler Apache::RubyRun.instance </Files> RubyRequire apache/eruby-run # Handle *.rhtml files as eRuby files <Files *.rhtml> SetHandler ruby-object RubyHandler Apache::ERubyRun.instance </Files> </IfModule> #AddType application/x-httpd-eruby .rhtmlAction application/x-httpd-eruby /cgi-bin/eruby Any ideas? Charles
Wilson Bilkovich
2006-Jul-02 02:19 UTC
[Rails] Eruby.import -> "uninitialized constant" error
On 6/30/06, mausolos <mausolos@gmail.com> wrote:> I''m working on porting a dynamic website done in PHP over to mod_ruby. I > have everything set up and working nicely (I can make a .rhtml page, put > ruby code between <% %> and it works etc), but when I try to use > "Eruby.import" as a sort of analog to PHP''s "require_once()", I run into > trouble. >That should be ERuby.import, not Eruby.
Aha! That was it! Thank you very much.. I love it when the answer is so simple! :) Charles "Wilson Bilkovich" <wilsonb@gmail.com> wrote in message news:d4e4955b0607011919r3ef61095l2caa876d4d9223e4@mail.gmail.com...> On 6/30/06, mausolos <mausolos@gmail.com> > wrote: >> I''m working on porting a dynamic website done in PHP over to mod_ruby. I >> have everything set up and working nicely (I can make a .rhtml page, put >> ruby code between <% %> and it works etc), but when I try to use >> "Eruby.import" as a sort of analog to PHP''s "require_once()", I run into >> trouble. >> > > That should be ERuby.import, not Eruby.