Merb and DataMapper

Initial Experience with Great Solutions

2008-03-12

I started a new project using Ruby on Rails. Unfortunately, ActiveRecord is so stringent in its requirements for database design that the legacy database I was working with was unusable. I had to look elsewhere for my ruby framework because using the legacy database was a primary requirement. The existing application needs to continue operating for many years to come. It serves its users very well.

I turned to Merb for my solution. Database ORM agnosticism was the order of the day. Merb does work with ActiveRecord but, since ActiveRecord did not work with me, I chose to use DataMapper. Sequel was another alternative. I prefer DataMapper (and merb, of course) for many reasons.

The community surrounding Merb and DataMapper is excellent. Many of the people that work on one project, work on the other. I began perusing the Google groups for each project. I checked out their Rubyforge pages. I read their websites and documentation. Most importantly, I participated in conversations on irc chat (irc.freenode.net, #merb and #datamapper). Then, I took the dive and it has been amazingly to easy to make the switch from Rails to Merb and DataMapper.

When I did happen to find something I wanted to change, a bug I wanted to fix, or brand new feature I wanted to add, the process was cake. The codebase is clean and well spec'd. In addition, both teams have well defined guidelines and processes for contributing to the project. If you are ever unable to find the answer to some question the IRC channels are always full of the core members of the team along with many other very experienced users. The IRC resource has been invaluable to me and since, I hope I've been able to help a few new users myself.

In terms of features both Merb and DataMapper are slightly behind the features of Rails (and the many, many plugins) but, all of the core requirements are there. Not only are the features in the core, they are much better than the equivalent features in Rails. For example, you can forget about ever having to write responds_to in every action you have ever again. Merb has a method, provides, which defines the this behavior.

My favorite feature in DataMapper, especially useful when working with a legacy database, is the capability to rename a column for use in your own model. For example, if the column in your database is named 'itm_mup' and you would prefer it be called 'item_markup' in your application.

Not only does Merb allow you to use one of the three most popular ORM's, it allows you to use RSpec for testing, as well as, any javascript library you would like. Adding to this flexibility, Merb brings back a feature that was destroyed by Rails: lightweight components. Merb refers to these as "parts". Parts are called on by views to render extremely modular subsets of functionality.

All in all, any deficiencies are more than made up for by the community, the codebase and ease of contribution, and the features of both Merb and DataMapper.