Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mod_ruby / eruby: intermittent failure to load file

0 views
Skip to first unread message

vor_...@hotmail.com

unread,
Mar 6, 2003, 10:49:28 PM3/6/03
to
I am having a problem using mod_ruby and eruby. I just installed the latest
stable tarballs of each on a Red Hat Linux 8.0 machine, and everything
seemed to be working just fine. In combination with REXML this really seems
to be the ticket for a simple web app I need.

However, now I'm having an intermittent problem. The .rhtml file I am
testing intermittently results in errors such as:
/tmp/Viewer.rhtml.10484.0:79: undefined method `create_submit' for
#<Object:0x40f3c338> (NoMethodError)
from /opt/ictools/ruby/lib/ruby/1.7/apache/eruby-run.rb:113:in `load'
from /opt/ictools/ruby/lib/ruby/1.7/apache/eruby-run.rb:113:in `run'
from /opt/ictools/ruby/lib/ruby/1.7/apache/eruby-run.rb:78:in `handler'
from ruby:0

I must admit I am a complete newbie at CGI and Apache in general (although
not Ruby). I could be doing something incredibly stupid. I'm still
basically at the playing around stage.

These are the relevant pieces of the code:

.... html header stuff
<%
require 'cgi'
require 'FormHelper' # a little helper class to generate some common forms
etc I need
include FormHelper

# some CGI and form stuff here
create_submit('blah', 'blah')
%>
..... html footer stuff

Because this error only happens about 1 out of 5 times I am completely
baffled. I've configured the browser to not use a cache at all (to try and
eliminate caching effects) yet it still fails in this manner.

I've never had Ruby 'sometimes' complain about not being able to find a
method. Style aside, what is wrong with the use of include above?

Can anyone help?

Thanks,

Brett Williams


Tim Bates

unread,
Mar 6, 2003, 11:02:37 PM3/6/03
to
On Fri, 7 Mar 2003 2:24 pm, vor_...@hotmail.com wrote:
> require 'FormHelper' # a little helper class to generate some common forms

> Because this error only happens about 1 out of 5 times I am completely


> baffled. I've configured the browser to not use a cache at all (to try and
> eliminate caching effects) yet it still fails in this manner.
>
> I've never had Ruby 'sometimes' complain about not being able to find a
> method. Style aside, what is wrong with the use of include above?
>
> Can anyone help?

Apache runs several child processes to handle incoming connections. By
default, it runs 5 under low loadings. mod_ruby caches scripts loaded using
'require', but the caching is separate for each child process. (Not really
'caching', but the actual way it does it is irrelevant.)

What is happening here is, one of your child processes is using and old
version of FormHelper (presumably) which doesn't contain the create_submit
method. When this particular child process answers your request, it fails.
Any other time, it works.

To force mod_ruby to reload the scripts, either restart Apache and/or use
'load' instead of 'require' in your script. The latter option will add some
loading overhead (since you no longer have a hot cache) and so once you're
sure FormHelper isn't going to change for a while, you can use 'require'
again to get the benefits of that caching.

Tim Bates
--
t...@bates.id.au

vor_...@hotmail.com

unread,
Mar 11, 2003, 11:37:08 PM3/11/03
to
"Tim Bates" <t...@bates.id.au> wrote in message
news:20030307143...@bates.id.au...

[snip]

> What is happening here is, one of your child processes is using and old
> version of FormHelper (presumably) which doesn't contain the create_submit
> method. When this particular child process answers your request, it fails.
> Any other time, it works.
>
> To force mod_ruby to reload the scripts, either restart Apache and/or use
> 'load' instead of 'require' in your script. The latter option will add
some
> loading overhead (since you no longer have a hot cache) and so once you're
> sure FormHelper isn't going to change for a while, you can use 'require'
> again to get the benefits of that caching.

Problem solved. Many thanks--dumb mistake by an apache newbie. Now, with
eruby-debug turned on things are going just great!

mod_ruby/eruby/REXML is just a joy to develop in. Thanks to everyone who
works on any of these. REXML has just completely spoiled me--I love the
API.

-- Brett Williams


0 new messages