Getting Started with eRuby


Step 1: Send a Ticket


Send in a ticket to the ASO team and ask for eRuby support for your shared hosting. They have to tweak something to enable the following files that we're going to set up.

Step 2: Set Up Your cgi-bin Folder


You need to add an "eruby" script to your ~/public_html/cgi-bin folder. Here's what it should look like:

#!/bin/sh
exec /usr/local/bin/eruby

Save the above file as ~/public_html/cgi-bin/eruby and change its permissions to be executable.

Step 3: Set Up Your .htaccess File


Finally, you'll need to create an .htaccess file in your ~/public_html/ folder and add the following three lines:

Action eruby-script /cgi-bin/eruby
AddHandler eruby-script .rhtml
DirectoryIndex index.html index.rhtml

This will cause any *.rhtml files to load the eruby script that we just set up, and that file in turn will send the rhtml file through the eruby parser before displaying it to the user.

Step 4: (Optional) Set Up a Rewrite Rule


If you don't like having a ".rhtml" hanging off the end of your URLs, you can add this to the .htaccess file as well:

RewriteEngine on
RewriteRule ^(.*)(?<!\.rhtml)$ $1.rhtml [L]

Done!


You should now be able to upload files ending in .rhtml that contain ruby code enclosed in <% %> or <%= %> markers and have the contents run as ruby:

<html>
<body>
1 and 2 is
<%= 1 + 2 %>
</body>
</html>

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki