Return to Programming Ruby Share

Originally created with PHP, this MVC was just recently rebuilt in Ruby. I chose not to use rails to learn and create my own framework.

Getting started with Ruby

I learnt Ruby overnight on janurary 24th with Chris Pine's Guide to ruby programming and managed to rebuild the entire XXIIVV CMS in a day, and under 1000 lines. Interestingly enough, Ruby comes with OS X so you can get started really quickly. This site is hosted on Mediatemple's (gs) servers and also has a ruby install.

It's often suggested to use rails when doing web development in ruby but you don't have to, I didn't. Apache won't print from .rb files with Mediatemple so I had to go through the PHP's exec as follow.

echo `/usr/bin/ruby index.rb 2>&1`; index.php

One difficulty that comes with not having rails is to get the url and the $_GET parameters - nothing that you can't hack together with the CGI object. The following lines will allow you to grab the index.php?name= into get_name.

require "cgi" index.rb
url_get = CGI.new
get_name = url_get['name'].gsub(/[^0-9a-z ]/i, '')
puts get_name

These 4 lines will echo the get value passed as /index.php?name=Daniel. In combination with htaccess' RewriteEngine you can already have /portfolio links with a railess ruby.