I’ve started learning Ruby on Rails after reading a book about ruby. But I was soon disappointed by the fact that I wasn’t learning ruby, but ‘rails’, which is not the same thing for me.

So, I’ve decided to go without rails for a little while. Having experience in web development I did choose to try the Ramaze framework, which I really like. One strange thing happened though. Once started with Ramaze, in need of some document I’ve found some screencasts on ‘The Pragmatic Programers’ called ‘Classy Web Development with Sinatra’. I’ve bought both screencasts, the first screencast is a really good small introduction to Sinatra. I’ve then realized that Sinatra is really great to create an API or a quick prototype of an application. So I’ve decided to prototype my ‘youtube niche’ application with Sinatra. Later on, my application became bigger and I felt It was wrong to continue using Sinatra for that, mainly because of the freedom (ie: lack of structure in this scenario), so I went back on Ramaze. The wonderful things that happens was that the models were still working without modification, the template require only really small modifications to work and the controller part was not too hard to modify to get working on my now new framework (mostly updating request params usage, renaming methods and putting them in separate files). Then my app became bigger and bigger. Ramaze was doing the job right and easily. But I’ve quickly realized that I was missing some facilities from the Rails framework. Shame on me, I know enough of Rails to know that I miss some stuff. The webapp is still in a working prototype phase, but I’m not gonna polish it to make a release…

I’m not turning my back to Ramaze nor Sinatra. In fact, I’ve promised myself to use Sinatra the next time I need to create an API or a web service. And for sure Ramaze is a good choice for small website/webapp, because it’s way lighter that Rails, so it can be run on a shared web hosting more easily. I know that a VPS is cheap nowadays, but sometime you just want to try stuff on a cheaper Dreamhost account.

The thing is, I have a lot of free time these days, so I’m experimenting. My next project may not be in Ruby, even if I really like it. Because I’ve been seeing an ex lately…

Why Ramaze instead or Rails or Merb? Because it’s a learning process, a Ruby learning process. I have build a website with Ruby on Rails, and I`ve thought: “Wow, this Ruby is a really nice language, let’s do something else with it.” Then I’ve realized how little I knew about the language, I knew rails, not Ruby.

So, being a web developer, I wanted to play with websites/web applications. Here’s where Ramaze come into play. Ramaze is not doing much for you, you have to know ruby to create something useful. In addition, Ramaze run well a Dreamhost account, where rails is slow in comparison (nothing against rails, but shared hosting is not the ideal solution for now). Another plus, in the Ramaze source code, there’s an example folder, with a lot of good code to look at like a Blog, a Facebook app and a Wiki. It’s so cleanly written, it almost make me want to quit my day job… oh wait, I’ve just been laid off for economic reasons, yeah, more time for coding.

I know that Ramaze won’t get me a new job, but It makes me smarter.

It’s easy to get Ramaze running on Dreamhost, as they are using Passenger. Here’s how:

Enabling Passenger

First log in to your Dreamhost control panel and go to you domain, you have to activate the option

Ruby on Rails Passenger (mod_rails)?

Then the setting for

Specify your web directory:

should point to the public folder in the directory where your ramaze application will live

Install gems in you home directory

Dreamhost does not provide the Ramaze gem, the easiest thing to do is to install your required gems in your home directory

First create a directory to hold the gems

mkdir ~/.gems

Then update your environment

~/.bash_profile

export GEM_HOME=$HOME/.gems
export GEM_PATH=$GEM_HOME:/usr/lib/ruby/gems/1.8

Then logout/login or execute this line to have your environment updated

source ~/.bash_profile

Now you can install your own gems

gem install ramaze --no-rdoc --no-ri

I’m using the flags to avoid generating the documentation, this is fairly process intensive and Dreamhost will probably kill you process. You should have your own development environment on your computer anyway if you need the doc

Creating a Ramaze app

I will not cover the creation of a Ramaze application, there is a lot of good tutorial already

Hosting your Ramaze app on Dreamhost

In the root of your application directory you need a rackup file for Passenger. ‘start’ being the bootstrap file for your application, this is needed as we need to update GEMPATH to our own gems, this cannot be done in the config.ru file for some obscure reason

config.ru

require 'start'

Ramaze.trait[:essentials].delete Ramaze::Adapter
Ramaze.start :force => true
run Ramaze::Adapter::Base

Now the important part, the start.rb file need to have information on your gems folder, right after the inclusion of rubygems

start.rb

require 'rubygems'
#needed to avoid the Passenger exception page every hour or so
Gem.clear_paths
#use my own gem when availlable
Gem.path.unshift('/path/to/my/home/.gems')

require 'ramaze'

# require all controllers and models
acquire __DIR__/:controller/'*'
acquire __DIR__/:model/'*'

That’s all folk! By the way, it should work with Merb too.