27158 total geeks with 3531 solutions
Recent challengers:
 Welcome, you are an anonymous user! [register] [login] Get a yourname@osix.net email address 

Articles

GEEK

User's box
Username:
Password:

Forgot password?
New account

Shoutbox
omentomikel
[b][url=http ://www.repli caomegawatch es.net/]repl ica omega[/url][ /b] [b][<str ong><a href="http:/ /www.replica omegawatches .net/">repli ca omega</a></s trong> <stro ng><a href="http:/ /www.replica omegawatches .net/">fake omega</a></s trong> <br>< strong><a href="htt
omentomikel
<strong><a href="http:/ /www.replica omegawatches .net/">repli ca omega</a></s trong> <stro ng><a href="http:/ /www.replica omegawatches .net/">fake omega</a></s trong> <br>< strong><a href="http:/ /www.replica omegawatches .net/">repli ca omega watches</a>< /strong> <br
omentomikel
[b]<a href="http:/ /www.vohek.n et/">New Balance</a>[ /b] [b][u<strong ><a href="http:/ /www.vohek.n et/">New Balance</a>< /strong> <br ><strong><a href="http:/ /www.vohek.n et/">New Balance outlet</a></ strong> <str ong><a href="http:/ /www.vohek.n et/">discoun t New
omentomikel
<strong><a href="http:/ /www.vohek.n et/">New Balance</a>< /strong> <br ><strong><a href="http:/ /www.vohek.n et/">New Balance outlet</a></ strong> <str ong><a href="http:/ /www.vohek.n et/">discoun t New Balance</a>< /strong> <br ><br><br><br ><br><br><br ><strong><a h
omentomikel
[b][url=http ://www.patek -philipe.com /patek-ladie s-watches-c- 6.html]l<str ong><a href="http:/ /www.patek-p hilipe.com/p atek-ladies- watches-c-6. html">ladies patek watches</a>< /strong> <br > <strong><a href="http:/ /www.patek-p hilipe.com/p atek-ladies- watches-c-6.

Donate
Donate and help us fund new challenges
Donate!
Due Date: Nov 30
November Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
title="Bastard
Operator from
Hell">BOFH:
WHERE did this
"fax-enabled"
"It is comforting
to know where your
data centres are."
UK.GOV does NOT
I need a password
to BRAKE? What? No!
STOP! Aaaargh!
Leaked screenshots
show next Windows
kernel to be a
perfect 10
HP boss Meg Whitman
shuffles exec pawns
just before biz
splits
Judge OKs $450m
deal to end ebook
price-hike row. And
Apple just won"t
let it die
Mozilla remembers
2013, back when it
still gobbled at
the Google
money-trough
Europe may ask Herr
Google: Would you
snap off your
search engine?
First in line to
order a Nexus 6?
AT&T has a
BRICK for you
Amazon warming up
"cheapo web video"
cannon to sink
Netflix
Slashdot
Critical XSS Flaws
Patched In
WordPress and
Popular Plug-In
Startup Assembly
Banks On Paid,
Open-Source Style
Development
Another Hint For
Kryptos
Mozilla"s 2013
Report: Revenue Up
1% To $314M; 90%
From Google
Molecular Clusters
That Can Retain
Charge Could
Revolutionize
Computer Memory
The EU Has a Plan
To Break Up Google
Top NSA Official
Raised Alarm About
Metadata Program In
2009
Obama"s Immigration
Order To Give Tech
Industry Some,
Leave "Em Wanting
More
CERN Releases LHC
Data
Harvard Scientists
Say It"s Time To
Start Thinking
About Engineering
the Climate
Article viewer

eRuby Basics



Written by:dimport
Published by:Nightscript
Published on:2003-06-21 07:19:46
Topic:Ruby
Search OSI about Ruby.More articles by dimport.
 viewed 12230 times send this article printer friendly

Digg this!
    Rate this article :
The first thing you need to know is what eRuby is. eRuby is simply a way of embedding Ruby code inside an HTML document. It is used just like ASP, JSP, and PHP, but it gives you all the power of Ruby instead. There are several different implementations of eRuby, including eruby and erb. This tutorial is going to discuss eruby.

There are three ways to embed Ruby inside an HTML document:

<% ruby code %>
 
<%= ruby expression %>
 
<%# ruby code %>
 


If you are familiar with ASP, JSP, or PHP, this should be very familiar to you (except for maybe that last one). The following examples will be run through the eruby program directly. Here's an example of using the first form:

This is embedded <% bleh = "Ruby"; print "#{bleh}!" %>
 


This statement would produce: This is embedded Ruby!Here's an example of using the second form:

<%bleh = "Ruby"%>This is embedded <%=bleh%>!
 


The output is the same as before. The last form of embedding Ruby is the same as the first. Pretty simple, huh? eRuby really isn't complicated, so long as you already know Ruby ;] OK, so you can run this stuff through the eruby program, but how do you get a webserver to run this? Simple. I'm going to show you how to use eruby with Apache.The first thing you need to do is copy the eruby program itself into your cgi-bin directory. Then you need to edit your httpd.conf file.

Add these two lines:
Quote:
AddType application/x-httpd-eruby .rhtmlAction application/x-httpd-eruby /cgi-bin/eruby
Now, whenever you want to use an HTML file with embedded Ruby, just rename the file with a .rhtml extension and you're ready to go. You can also add or replace your DirectoryIndex directive so that index.rhtml is searched for.

For example:
Quote:
DirectoryIndex index.html index.shtml index.rhtml
Pretty easy. And, if you're using Apache and want faster access, you can always download and install mod_ruby.Well, that's it for now. For more information about eRuby, check out the Ruby documentation (that's where I got this info).

This article was originally written by vektor

Did you like this article? There are hundreds more.

Comments:
Anonymous
2007-05-31 09:07:31
this does not work in apache for xp, what do you mean copy the eruby program itself into your cgi-bin directory?? its a directory structure
Anonymous
2011-06-28 23:48:10
Indeed you make this complicate stuff accesible for everyone! you are a genius without <a href="http://www.xlpharmacy.com/">Generic Viagra</a>
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:


Blogs: (People who have posted blogs on this subject..)
reacher
The Ruby Way on Wed 27th Aug 6pm
I've recently come back to OSIX and taken all the challenges again. This next time around, however, I'm using Ruby to tackle them. I will admit that my old C versions of some solutions ran faster (especially the brute force ones), but coding the Ruby ve
bb
Ruby on Rails on Tue 10th Oct 9am
I installed ruby and wrote my first ruby on rails web application. It was quite an enjoyable experience. Certainly more fun than asp.net (which is bloody unproductive) I suggested we knock some internal application up in it for my company to have ap


     
Your Ad Here
 
Copyright Open Source Institute, 2006