[#6363] Re: rescue clause affecting IO loop behavior — ts <decoux@...>

>>>>> "D" == David Alan Black <dblack@candle.superlink.net> writes:

17 messages 2000/11/14
[#6367] Re: rescue clause affecting IO loop behavior — David Alan Black <dblack@...> 2000/11/14

Hello again --

[#6582] best way to interleaf arrays? — David Alan Black <dblack@...>

Hello --

15 messages 2000/11/26

[#6646] RE: Array Intersect (&) question — Aleksi Niemel<aleksi.niemela@...>

Ross asked something about widely known and largely ignored language (on

23 messages 2000/11/29
[#6652] RE: Array Intersect (&) question — rpmohn@... (Ross Mohn) 2000/11/29

aleksi.niemela@cinnober.com (Aleksi Niemel) wrote in

[#6723] Re: Array Intersect (&) question — Mathieu Bouchard <matju@...> 2000/12/01

> >Use a hash. Here's code to do both and more. It assumes that

[#6656] printing/accessing arrays and hashes — raja@... (Raja S.)

I'm coming to Ruby with a Python & Common Lisp background.

24 messages 2000/11/30

[ruby-talk:5989] Re: html, forms, ruby and apache

From: Jim Menard <jimm@...>
Date: 2000-11-02 13:40:01 UTC
List: ruby-talk #5989
Johann Spies <jhspies@adept.co.za> writes:

> What I want to do learn is how to use a browser like netscape to
> handle database queries with ruby and Postgresql as backend.  I was
> also considering php as an alternative because one can embed it in an
> html-document.

Here is some cut-and-paste help. I don't cover installing PostgreSQL or
installing mod_ruby or eruby here.

Here's what I put in my httpd.conf file:

================================================================

# Problem: for some reason, mod_ruby.so has the library name "liberuby.so.0.1"
# compiled in. I want to use "liberuby.so.0.1.2" instead.
#
# solution: Must create link in /usr/local/lib from liberuby.so.0.1 to
# liberuby.so.0.1.2.

LoadModule ruby_module /usr/lib/apache/mod_ruby.so
AddModuler ruby-script .rb
AddType application/x-httpd-ruby .rb

# mod_ruby's eruby support
AddType application/x-httpd-eruby .rhtml

================================================================

Here's an example eruby .rhtml file that hits the database (thanks to Dave
Thomas for posting bits of Chapter 14 from his book).

================================================================
<html>
<head>
<title>Ruby and PostgreSQL Test</title>
</head>
<body bgcolor="white">
<pre>
<%
require 'postgres'

# Get dbname, username, and password from somewhere. No, you can't have
# mine :-)
conn = PGconn.connect('localhost', 5432, '', '', dbname, username, password)
csr = conn.exec("select * from sometable")
csr.fields.each { | column_name |
    print "#{column_name}\t"
}
print "\n"
csr.result.each { | row |
    row.each { | column |
	print "#{column}\t"
    }
    print "\n"
}
%>
</pre>
</body>
</html>
================================================================

Jim
-- 
Jim Menard   jimm@io.com   http://www.io.com/~jimm/   BeOS developer #1283
"What's a Superbowl? Does it save the city from ruin and destruction ON TOP
OF containing some part of a complete breakfast?" -- J. on alt.fan.tom-servo

In This Thread