Hello list,
let me throw in a friendly hello first - I'm new to the list and new to ruby
in general as well.
I've come across ruby some days ago in a newspaper article and wanted to give
it a try, mainly because I need something to play with that's different from
what I'm normally doing. After reading through some articles I got fascinated
from some of the concepts and am currently trying to rewrite some smaller web
projects to get used to it.
I didn't make it past the planning though because I encountered some problems.
I've looked through the web for results, but I couldn't find anything related
and don't know where to extend my search to. So, in case of my problem being
covered somewhere or there being a good page on mod_ruby/eruby I would really
be happy if you could point me to it.
Now, my problem: I got some strange error from embedded eruby: "in:
`each_hash': NULL pointer given (ArgumentError)" that doesn't occur when
doing
'eruby scriptname.rhtml' on the command line.
I installed latest mod_ruby/eruby version on apache2, mandrake linux 10. I
also installed latest ruby mysql version. The basic installation has been
tested with the following script and it worked fine:
<%
require "mysql"
#~-----------------------------------------------------------------------------
m = Mysql.new("localhost", "user", "pass");
m.select_db("test");
result = m.query("SELECT * FROM words");
result.each do |array|
array.each do |value|
puts value
end
puts
end
m.close
#~-----------------------------------------------------------------------------
%>
Then I wrote another simple script(better, copied it from
http://www.rubywizard.net/ruby-mysql.html)
<%
require "mysql"
#~-----------------------------------------------------------------------------
m = Mysql.new("localhost", "user", "pass");
m.select_db("test");
result = m.query("SELECT * FROM words");
result.each_hash {|hash|
printf("%s %s %s<br>", hash['english'], hash['german'], hash['french'])
}
m.close
#~-----------------------------------------------------------------------------
%>
This one throws above error. Let me post that error again in more details:
[Thu Nov 18 13:56:28 2004] [notice] Apache-AdvancedExtranetServer/2.0.48
(Mandrake Linux/6.6.100mdk) PHP/4.3.9 mod_ruby/1.0.7 Ruby/1.8.0
mod_ssl/2.0.48 OpenSSL/0.9.7c DAV/2 configured -- resuming normal operations
[Thu Nov 18 13:56:34 2004] [error] mod_ruby: error in ruby
/tmp/test.ruby.23657.0:10:in `each_hash': NULL pointer given (ArgumentError)
from /tmp/test.ruby.23657.0:10
from /usr/lib/ruby/1.8/apache/eruby-run.rb:113:in `load'
from /usr/lib/ruby/1.8/apache/eruby-run.rb:113:in `run'
from /usr/lib/ruby/1.8/apache/eruby-run.rb:78:in `handler'
As the script works from outside apache I believe in some configuration issue.
The apache config file looks good though and I cannot imagine what to change
in order to get script2 working same as script1. In any case, here's the
config file:
LoadModule ruby_module /usr/lib/apache2-extramodules/mod_ruby.so
<IfModule mod_ruby.c>
RubyRequire apache/ruby-run
<Location /ruby>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
Options ExecCGI
</Location>
<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
Options ExecCGI
</Files>
RubyRequire apache/eruby-run
<Location /eruby>
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance
</Location>
<Files *.ruby>
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance
</Files>
<Files *.rhtml>
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance
</Files>
</IfModule>
Now, I could be completley wrong about asking you because it being a mysql
problem only (it just doesn't look like that and I've to start somewhere:-))
- in that case let me say sorry in advance.
Best regards,
Thomas