eRuby

Hello,

I want to try out eRuby. I am only a regular user, so I can’t install
mod_ruby and I can’t mess with Apache.

However, I have enough space in my home directory to install eRuby.

Can anyone tell me how I can use eRuby with what I have?

One thought is to make a cgi program which simply calls eRuby and then
outputs what ever eRuby returns. This solution is a bit ugly though.
Plus, I’d have trouble if I ever want the eRuby program to receive CGI
parameters.

Thanks for the help.

Daniel Carrera
Graduate Teaching Assisant. Math Dept.
University of Maryland. (301) 405-5137

Can anyone tell me how I can use eRuby with what I have?

AFAIK eruby takes a document containing a Ruby code and replaces the
code with its output.
The Ruby code must be either enclosed in <% and %> or the lines must start
with %.

The simplest way to use eruby is from command line:
eruby <your_file>
which is usefull for quick testing.

One thought is to make a cgi program which simply calls eRuby and then
outputs what ever eRuby returns. This solution is a bit ugly though.
Plus, I’d have trouble if I ever want the eRuby program to receive CGI
parameters.

If you do not have mod_ruby then this solution is perfectly usable (I do not
consider it ugly) and it is also arguably better than using plain Ruby. Try
CGI library (included in the default installation) for parsing the
parameters.
Here is a part of my code:

% require ‘cgi’

… cgi headers here

% myvars = CGI::parse(ENV[‘QUERY_STRING’] || ‘’)
% myvars.each { |key, val|
% puts “#{key} = #{val}”
% puts “

% }

Regards,

Dalibor Sramek

···

On Sun, Dec 08, 2002 at 11:14:51AM +0900, Daniel Carrera wrote:


Dalibor Sramek “In the eyes of cats, all things belong to cats.”
dali@insula.cz

After much time and numereous attempts, I did the following to get both
Ruby and eRuby working for me.

What follows assumes telnet access and a directory (cgi-bin for me) that
is recognized by the system as an active cgi script directory.

Start description ==============================

  1. installed Ruby using the -prefix=/my/path/to/ruby directory option
    If you need to, use ./configure --help to review options.

  2. installed eRuby
    If necessary, change the shebang #! line in configure.rb
    to point to the location of ruby, i.e.,
    #!/my/path/to/ruby

  3. created a .htaccess file in my “webdocuments” directory that contained

AddHandler cgi-script rb rbx

AddHandler application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/eruby

  1. moved eRuby to my cgi-bin directory

  2. created GetEnv.rhtml containing:

eruby example

Enumeration

    <%(1..10).each do|i|%>
  • number <%=i%>
  • <%end%>

Environment variables

<%ENV.keys.sort.each do |key|%> <%end%>
<%=key%><%=ENV[key]%>
  1. created testRuby.rbx containing:
    #!/my/path/to/ruby

This is a working ruby script running ruby script with

extension .rb or .rbx

If the key for ENV does not exist, then ruby returns nil.

It requires the following modification to .htaccess in www

AddHandler cgi-script rb rbx

···

require ‘date’
print “Content-type: text/html\n\n”
d = Date.new(2000, 3, 31)
print $:,‘


print ENV[‘RUBYPATH’],‘

print [d.year, d.yday, d.wday]
print “this is a test.”, ENV[‘PATH’], “prefix= “,ENV[‘prefix’],”

names = [“john”, “mary”, “”, 4]
data = [1, 2, 3, 4]
data.each do |i |
print i, " “, names[i-1],”
"
end
print “

Environment variables


ENV.keys.sort.each do |key|
print “”
print “”
end
print “
”,key,“”, ENV[key], “

  1. Ran GetEnv.rhtml and testRuby.rbx

  2. They worked.
    WOW! EXCITEMENT!
    PHYSICAL EXPRESSIONS OF JOY!
    GREAT SENSE OF SATISFACTION! YES! WELL DONE!

  3. Hope you have the same result – a sense of accomplishment
    and the joy of working with Ruby and eRuby.
    End description =============================

12/7/2002 8:14:51 PM, Daniel Carrera dcarrera@math.umd.edu wrote:

Hello,

I want to try out eRuby. I am only a regular user, so I can’t install
mod_ruby and I can’t mess with Apache.

However, I have enough space in my home directory to install eRuby.

Can anyone tell me how I can use eRuby with what I have?

One thought is to make a cgi program which simply calls eRuby and then
outputs what ever eRuby returns. This solution is a bit ugly though.
Plus, I’d have trouble if I ever want the eRuby program to receive CGI
parameters.

Thanks for the help.

Daniel Carrera
Graduate Teaching Assisant. Math Dept.
University of Maryland. (301) 405-5137

Also, be sure to chmod on any rb or rbx files to make them
executable, i.e., mod 755

After much time and numereous attempts, I did the following to get both
Ruby and eRuby working for me.

What follows assumes telnet access and a directory (cgi-bin for me) that
is recognized by the system as an active cgi script directory.

Start description ==============================

  1. installed Ruby using the -prefix=/my/path/to/ruby directory option
    If you need to, use ./configure --help to review options.

  2. installed eRuby
    If necessary, change the shebang #! line in configure.rb
    to point to the location of ruby, i.e.,
    #!/my/path/to/ruby

  3. created a .htaccess file in my “webdocuments” directory that
    contained

···

12/8/2002 8:09:09 AM, John Feezell JohnFeezell@3wplace.com wrote:

AddHandler cgi-script rb rbx

AddHandler application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/eruby

  1. moved eRuby to my cgi-bin directory

  2. created GetEnv.rhtml containing:

eruby example

Enumeration

    <%(1..10).each do|i|%>
  • number <%=i%>
  • <%end%>

Environment variables

<%ENV.keys.sort.each do |key|%> <%end%>
<%=key%><%=ENV[key]%>
  1. created testRuby.rbx containing:
    #!/my/path/to/ruby

This is a working ruby script running ruby script with

extension .rb or .rbx

If the key for ENV does not exist, then ruby returns nil.

It requires the following modification to .htaccess in www

AddHandler cgi-script rb rbx

require ‘date’
print “Content-type: text/html\n\n”
d = Date.new(2000, 3, 31)
print $:,‘


print ENV[‘RUBYPATH’],‘

print [d.year, d.yday, d.wday]
print “this is a test.”, ENV[‘PATH’], “prefix= “,ENV[‘prefix’],”

names = [“john”, “mary”, “”, 4]
data = [1, 2, 3, 4]
data.each do |i |
print i, " “, names[i-1],”
"
end
print “

Environment variables


ENV.keys.sort.each do |key|
print “”
print “”
end
print “
”,key,“”, ENV[key], “

  1. Ran GetEnv.rhtml and testRuby.rbx

  2. They worked.
    WOW! EXCITEMENT!
    PHYSICAL EXPRESSIONS OF JOY!
    GREAT SENSE OF SATISFACTION! YES! WELL DONE!

  3. Hope you have the same result – a sense of accomplishment
    and the joy of working with Ruby and eRuby.
    End description =============================

12/7/2002 8:14:51 PM, Daniel Carrera dcarrera@math.umd.edu wrote:

Hello,

I want to try out eRuby. I am only a regular user, so I can’t install
mod_ruby and I can’t mess with Apache.

However, I have enough space in my home directory to install eRuby.

Can anyone tell me how I can use eRuby with what I have?

One thought is to make a cgi program which simply calls eRuby and then
outputs what ever eRuby returns. This solution is a bit ugly though.
Plus, I’d have trouble if I ever want the eRuby program to receive CGI
parameters.

Thanks for the help.

Daniel Carrera
Graduate Teaching Assisant. Math Dept.
University of Maryland. (301) 405-5137

After much time and numereous attempts, I did the following to get both
Ruby and eRuby working for me.

[…]

Archived at
http://www.rubygarden.org/ruby?GavinSinclair/GettingErubyToWork

I have no idea what its all about, but since it’s been a hot issue recently,
hopefully it’ll be useful in future.

Gavin

···

From: “John Feezell” JohnFeezell@3wplace.com

Thanks. But what is a ‘.htaccess’ file?

After I created it I couldn’t view any of my webpages online.
The browser said:

Forbidden
You don’t have permission to access /~dcarrera/ruby/0.2/first_steps.html
on this server.

Perhaps I have to add something to the .htaccess file to make the files
world readable?

Daniel Carrera
Graduate Teaching Assisant. Math Dept.
University of Maryland. (301) 405-5137

···

On Sun, 8 Dec 2002, John Feezell wrote:

After much time and numereous attempts, I did the following to get both
Ruby and eRuby working for me.

What follows assumes telnet access and a directory (cgi-bin for me) that
is recognized by the system as an active cgi script directory.

Start description ==============================

  1. installed Ruby using the -prefix=/my/path/to/ruby directory option
    If you need to, use ./configure --help to review options.

  2. installed eRuby
    If necessary, change the shebang #! line in configure.rb
    to point to the location of ruby, i.e.,
    #!/my/path/to/ruby

  3. created a .htaccess file in my “webdocuments” directory that contained

AddHandler cgi-script rb rbx

AddHandler application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/eruby

  1. moved eRuby to my cgi-bin directory

  2. created GetEnv.rhtml containing:

eruby example

Enumeration

    <%(1..10).each do|i|%>
  • number <%=i%>
  • <%end%>

Environment variables

<%ENV.keys.sort.each do |key|%> <%end%>
<%=key%><%=ENV[key]%>
  1. created testRuby.rbx containing:
    #!/my/path/to/ruby

This is a working ruby script running ruby script with

extension .rb or .rbx

If the key for ENV does not exist, then ruby returns nil.

It requires the following modification to .htaccess in www

AddHandler cgi-script rb rbx

require ‘date’
print “Content-type: text/html\n\n”
d = Date.new(2000, 3, 31)
print $:,‘


print ENV[‘RUBYPATH’],‘

print [d.year, d.yday, d.wday]
print “this is a test.”, ENV[‘PATH’], “prefix= “,ENV[‘prefix’],”

names = [“john”, “mary”, “”, 4]
data = [1, 2, 3, 4]
data.each do |i |
print i, " “, names[i-1],”
"
end
print “

Environment variables


ENV.keys.sort.each do |key|
print “”
print “”
end
print “
”,key,“”, ENV[key], “

  1. Ran GetEnv.rhtml and testRuby.rbx

  2. They worked.
    WOW! EXCITEMENT!
    PHYSICAL EXPRESSIONS OF JOY!
    GREAT SENSE OF SATISFACTION! YES! WELL DONE!

  3. Hope you have the same result – a sense of accomplishment
    and the joy of working with Ruby and eRuby.
    End description =============================

12/7/2002 8:14:51 PM, Daniel Carrera dcarrera@math.umd.edu wrote:

Hello,

I want to try out eRuby. I am only a regular user, so I can’t install
mod_ruby and I can’t mess with Apache.

However, I have enough space in my home directory to install eRuby.

Can anyone tell me how I can use eRuby with what I have?

One thought is to make a cgi program which simply calls eRuby and then
outputs what ever eRuby returns. This solution is a bit ugly though.
Plus, I’d have trouble if I ever want the eRuby program to receive CGI
parameters.

Thanks for the help.

Daniel Carrera
Graduate Teaching Assisant. Math Dept.
University of Maryland. (301) 405-5137

The following site gives information on the .htaccess file.
It is used with the Apache web server.
http://apache-server.com/tutorials/ATusing-htaccess.html

Your file name is given as “first_steps.html” but for eRuby
it should be rhtml, i.e., “first_steps.rhtml” and for
Ruby the file extension should be either .rb or .rbx with
.rbx being the “preferred” one, I believe.

Also be sure for any Ruby files (.rbx) that the permissions are
set to 755. On the eRuby files (.rhtml) should be set so that
the owner can rw., the group can r…, and other can r… that is
mod 644.

To verify that you can access the site via the browser, create
the following file and place it in the directory. Then in
the browser enter the URL:
http://your.host.com/~dcarrera/ruby/0.2/index.html

Create index.html using the following:

Test Access Testing access via the browser.
···

+++++++++++++

12/8/2002 3:18:50 PM, Daniel Carrera dcarrera@math.umd.edu wrote:

Thanks. But what is a ‘.htaccess’ file?

After I created it I couldn’t view any of my webpages online.
The browser said:

Forbidden
You don’t have permission to access /~dcarrera/ruby/0.2/first_steps.html
on this server.

Perhaps I have to add something to the .htaccess file to make the files
world readable?

Daniel Carrera
Graduate Teaching Assisant. Math Dept.
University of Maryland. (301) 405-5137

On Sun, 8 Dec 2002, John Feezell wrote:

After much time and numereous attempts, I did the following to get both
Ruby and eRuby working for me.

What follows assumes telnet access and a directory (cgi-bin for me)
that
is recognized by the system as an active cgi script directory.

Start description ==============================

  1. installed Ruby using the -prefix=/my/path/to/ruby directory option
    If you need to, use ./configure --help to review options.

  2. installed eRuby
    If necessary, change the shebang #! line in configure.rb
    to point to the location of ruby, i.e.,
    #!/my/path/to/ruby

  3. created a .htaccess file in my “webdocuments” directory that
    contained

AddHandler cgi-script rb rbx

AddHandler application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/eruby

  1. moved eRuby to my cgi-bin directory

  2. created GetEnv.rhtml containing:

eruby example

Enumeration

    <%(1..10).each do|i|%>
  • number <%=i%>
  • <%end%>

Environment variables

<%ENV.keys.sort.each do |key|%> <%end%>
<%=key%><%=ENV[key]%>
  1. created testRuby.rbx containing:
    #!/my/path/to/ruby

This is a working ruby script running ruby script with

extension .rb or .rbx

If the key for ENV does not exist, then ruby returns nil.

It requires the following modification to .htaccess in www

AddHandler cgi-script rb rbx

require ‘date’
print “Content-type: text/html\n\n”
d = Date.new(2000, 3, 31)
print $:,‘


print ENV[‘RUBYPATH’],‘

print [d.year, d.yday, d.wday]
print “this is a test.”, ENV[‘PATH’], “prefix= “,ENV[‘prefix’],”

names = [“john”, “mary”, “”, 4]
data = [1, 2, 3, 4]
data.each do |i |
print i, " “, names[i-1],”
"
end
print “

Environment variables


ENV.keys.sort.each do |key|
print “”
print “”
end
print “
”,key,“”, ENV[key], “

  1. Ran GetEnv.rhtml and testRuby.rbx

  2. They worked.
    WOW! EXCITEMENT!
    PHYSICAL EXPRESSIONS OF JOY!
    GREAT SENSE OF SATISFACTION! YES! WELL DONE!

  3. Hope you have the same result – a sense of accomplishment
    and the joy of working with Ruby and eRuby.
    End description =============================

12/7/2002 8:14:51 PM, Daniel Carrera dcarrera@math.umd.edu wrote:

Hello,

I want to try out eRuby. I am only a regular user, so I can’t install
mod_ruby and I can’t mess with Apache.

However, I have enough space in my home directory to install eRuby.

Can anyone tell me how I can use eRuby with what I have?

One thought is to make a cgi program which simply calls eRuby and then
outputs what ever eRuby returns. This solution is a bit ugly though.
Plus, I’d have trouble if I ever want the eRuby program to receive CGI
parameters.

Thanks for the help.

Daniel Carrera
Graduate Teaching Assisant. Math Dept.
University of Maryland. (301) 405-5137