Wednesday, May 21, 2008

Merb Sherb for Newbies | Part I

Just when I thought I had gotten a good enough handle on Rails, there comes Merb. Well, lets give it a spin, I thought. People I had spoken to (like my friend Peento at mdialog.com or Jarrod at Organic) seemed to think it was great, better than Rails, lighter than Rails etc etc.
So, I decided to give it a spin. First a couple of things:
  • I wont be able to post everything I did in this post for the very simple reason I am not done
  • I also intend this as a tutorial for newbies, who may be struggling with it (just as I did). Well, call me stupid :-) or slow - your pick. If you like this tutorial, please let me know
So, to start off with, hit the site http://merbivore.com .  This is the home page of the Merb framework. A good starting could have been http://wiki.merbivore.com. But it is kinda well, work in progress. however look at the tutorials link. The best tutorial that has ben kept upto date with the frequent changes in the code base is SLAPP
I indeed spent a lot of time going over old articles and tutorials that did not match the current state of merb.

Installation
Pre-requisites: Have Ruby and gem installed - which hopefully you do. Also, have a database installed. I like MySQL, and that is what is going to be used here.

Step 1: Install merb. You can do that using this command line:
$ sudo gem install merb --include-dependencies
This should install Merb. NOTE: As of writing the tutorial, Merb was on version 0.9.3. Things could change fast in the next major release and this tutorial could be useless (unless I update it). 
Now, there are a couple of steps that you should also perform:
$ sudo gem sources -a http://merbivore.com
What this does is add merbivore.com to the list of place gem looks for when searching for updates to gems. Merb is a fast moving project, with lots of changes going in frequently. So,  you may want to do this frequently as well:
$ sudo gem install merb activerecord merb_activerecord merb_helpers rspec merb_rspec
This will make sure the gems required for Merb are installed. Note that Merb supports three different ORM tools. However, I am familiar with ActiveRecord due to my Rails background, and that is what I am making sure in installed.
At this point, you should have Merb installed. 

Step 2: Creating a Skeleton App
This is really simple and close to how you would do it in rails:
$ merb-gen app Helloworld
So there! merb-gen is a generator which does several useful things. Think of it as rails and script/generate in Rails. Now you should a bunch of directories inside the directory HelloWorld. Take a look, poke around. You will see some differences from Rails. The ones I noticed immediately were around lack of model information. No database.yml, no model directory, or migrations stuff. I didn't know whether to be happy or sad. But that we will discuss in the next part when I take the generated app and try and configure it.

Arch with a Mac(h)| Enterprise Architecture and Mac's

I recently turned independant. Formed my own company called Agiliant Enterprises. I am currently working for a large mining company called Vale Inco in Toronto. I am part of the tenterprise architecture team doing interesting stuff. One of the comments the director of the group had when he saw my Macbook Pro -
You are the first Enterprise Architect I have seen with a Mac.
I took it as a compliment - a personal preference had turned into a differentiator.
However, let me give a you preview of life with a Mac. I have been using MS operating systems for a long long time. I started with DOS 1.1 and followed it closely. However like most windows user, I was frustrated with the stability and virus issues. Since OS X, I noticed the core Unix (Mac OS is based on BSD) underneath the pretty GUI. I have done most of my development work on Unix systems, with Solaris being my favourite Unix flavour. I was hooked. The thought that I could open up terminals and do things like gawk, grep, lexx, yacc, top..... you get the point.
So how do you use the tools that need Win to run? Things like ErWin database modeling, Rational Rose modeling etc? Simple - Use Parallels. It is an amazing piece of software - Viva La Virtualization. It evens runs faster and better than Windows by itself. No more crashing.

For some other things, I needed to get alternatives which also work great. For Visio, I installed ConceptDraw which is a great program. I also use Ms Office products on Mac.
Plus, as a free lancer, I am not tied to corporate standards for email. I us my gmail and yahoo accounts with Mac Mail application. and boy is it amazing....

he real reason for getting onto Mac - Rails team uses mac. I was hooked... here is a group of serious programmers doling out kick ass software on a Mac. I could too...

A nice side benefit - My documents look awesome impressing almost all clients ...
so Mac it is for a while....

ps: There are still things I dont like about MAc - too locked down.. but I am not complaining just yet...