Friday, January 26, 2007

(1..9).to_a.reverse.join(" ") + " Go !"

If you want to go camping right now, you'll need the following: (to be installed in this order)
  • Ruby

  • Rubygems

  • sqlite

  • The Camping-gem

  • Camping extras

If you need a detailed installation-guide, look at the camping-wiki.

Lets start our camping-trip with a jump in the cold water:

require 'camping'

Camping.goes :Simple

module Simple::Controllers
class Index < R '/'
def get
render :index
end
end
end

module Simple::Views
def layout
html do
head do
title 'my camping site'
end
body do
self << yield
end
end
end

def index
p "hello world"
end
end

Well, before I add some explanations, I recommend to play around with this very simple peace of code. What about adding a link, for example?

a "Google", :href => "http://www.google.com/"

Or adding a new page?
Explanations will follow, but you'll learn a lot by fiddling your way through some simple additions to the still very simple code.