Ruby on Ramaze

RamazeRamaze is a simple, light and modular open-source web application framework written in Ruby as an alternative to the Ruby on Rails framework. It aims to make the development simple and fun.

The main idea is that you can simply build a web application in a single Ruby file. Just install Ramaze and you are ready to go:

gem install ramaze

The following example shows the simplist form of a Ramaze application. (note the last line that starts the Ramaze server):

require 'rubygems'
require 'ramaze'
class MainController < Ramaze::Controller
  def index
    'Hello, World!'
  end
end
Ramaze.start

By default, MainController maps to '/'. Public controller methods are actions that are accessible via the web. But private controller methods are helpers that you can use in your views (like Rails helpers).

In the previous example, the index method will be called by default and the return value, "Hello, World!" will be rendered to the browser.

To pass parameters to your action, you can just use normal Ruby method arguments.

def add(a, b)
  sum = a.to_i + b.to_i
  "#{a} + #{b} = #{sum}"
end

Now, to access this action, navigate to http://localhost:7000/add/3/4 and you will get the sum of the two numbers rendered. By the way, 7000 is the default port for Ramaze.

Another nice feature, is that errors are automatically redirected to the error action in your controller so you can easily handle them.

Regarding views, Ezamar is the default templating engine shipped with Ramaze. But it supports other engines like Erubis, Haml, Liquid and RedCloth. Also, it ships with the light JQueryJavaScript library.

Also, Ramaze supports any Ruby ORM like ActiveRecord, Datamapper, Sequel, etc. And it supports most deployment solutions like Mongrel, Thin, fastcgi, Apache, Nginx, etc.

Unlike Rails, Ramaze is thread-safe and runs much faster. Currently, it runs on Ruby 1.9.

For more information, check out these screencasts and download the official book.

Did you like this article? Bookmark it:

Related Articles

Leave a Comment

If you want to post code, do this:
<pre><code class="ruby|javascript|css|html"> your code here </code></pre>