RasPi on Rails

... or Ruby on RasPi...

I recently acquired a Raspberry Pi (fantastic bit of hardware!). If you dont know anything about it, you should check it out here raspberrypi.org.

Anyway, I have a friend who is currently head over heels in love with Ruby. Typically, whatever he loves I end up hating, and vice versa (don't ask me to explain it!). So I figured I find out just how "horrible" Ruby is.

My raspi was just sitting there with nothing much to do, so I told it to install ruby, along with all its other gemmy goodness. This was the first time I attempted install ruby, and this is what I did:

Step One: Install it

1. Install  ruby:
sudo apt-get install ruby 

2. Install a ruby web server:
sudo gem install sinatra

Step Two: Write it

1. Create a simple ruby file:
vim test.rb

2. Enter the contents as follows:
require 'rubygems'
require 'sinatra'
get '/test' do
   "It Works!"
end

Step Three: Run it

1. Run the file (dont forget the ampersand, so that we can continue with the rest of this):
ruby test.rb &

Step Four: Test it

1. You can browse to the site at http://<ip>:4567/test, or alternatively:
wget 127.0.0.1:4567/test

2. Verify that it worked:
cat test

3. You should see this:
It Works!

So easy! I couldn't believe how simple it actually was. Maybe my friend is on to something here...

Let the hacking begin!