Eruby.import -> "uninitialized constant" error

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:inhandler’

  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

RubyRequire apache/ruby-run

Execute *.rbx files as Ruby scripts

<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance

RubyRequire apache/eruby-run

Handle *.rhtml files as eRuby files

<Files *.rhtml>
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance

#AddType application/x-httpd-eruby .rhtmlAction
application/x-httpd-eruby
/cgi-bin/eruby

Any ideas?
Charles

On 6/30/06, mausolos [email protected] 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! :slight_smile:

Charles

“Wilson B.” [email protected] wrote
in message
news:[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs