Merb
Merb is a web development framework, implemented in Ruby. Having grown out of the Ruby on Rails community, Merb benefitted significantly from the lessons that had been learnt from working with Rails. The Merb team went on to make a “Faster, Lighter, More Agile” framework, which clearly owed a lot to the excellent design of Ruby on Rails.
Like Rails, Merb is designed to use the MVC design pattern and favours the convention over configuration design paradigm. Rails likes to define a default Object Relational Mapper (ORM), a preferred JavaScript library, a default testing framework (etc.). The Merb ethos differs slightly in that Merb prefers you to chose which ORM or testing framework is most suitable for the task at hand.
In December 2008 it was announced that the Rails and Merb projects would be merging to form Rails 3, allowing many of the ideas and improvements that had been included in Merb to be incorporated back into Rails. Rails 3 will be a very interesting version to watch…
Articles on Merb
Deploying Merb with Vlad
You’ve built your Merb app, and you want to get it running on your web server. You could use Capistrano, but if you prefer the simple things in life you might find that Vlad is a better fit.
Installing Merb, DataMapper and Postgres on Ubuntu
This isn’t particularly difficult, but if you’re not familiar with Postgres on Ubuntu it could take you ten minutes to work it out:
$ sudo apt-get install postgresql-8.2 postgresql-server-dev-8.2 -y
$ sudo apt-get install libsqlite3-dev -y
$ sudo gem install merb do_postgresThe merb gem depends on the do_sqlite3 DataMapper database driver, so we need the libsqlite3-dev package in order to compile it. You can remove it afterwards if you like.
Installing merb with thor
Update (22 October): Things move very fast around here – the merb.thor file has been overhauled and now all you have to do to get the latest edge is download a single .thor file and run one command.
Matt Aimonetti wrote a neat post on installing merb edge with thor. Thor seems to have become the defacto technique for installing merb edge these days, and I’m going to give it a go in preference to installing merb with sake, as I had been doing.
Since Matt wrote his article the merb.thor file underwent a serious overhaul during the sprint at MerbCamp – what you need to do these days is quite a bit simpler:
curl -L http://merbivore.com/merb.thor > merb.thor
sudo thor merb:stack:install --edgeThe source code for all the Merb gems will be checked out into a directory called ./src.
To get the full low down on how to use Thor with Merb, head over to the Thor Howto on the excellent new Merb wiki.
Merb and DataMapper on the edge
I’ve just started writing a new app with merb and datamapper, so decided to start out on the edge. The preferred way to do it these days is with sake, a tool for running system wide rake tasks. It’s rather neat, and should (in theory) have made my installation of the edge versions of merb and datamapper extremely easy.
I did hit a couple of issues running them on Ubuntu 7.10, hence this article…
Testing Merb controllers with RSpec
I’ve been trying out Merb recently, and I’m liking it. However, I’ve spent a lot of time stumbling around the interweb looking for examples of what I’ve been trying to achieve. So far I’ve been coming up short. The Merb API docs are good, but you can’t beat a good example.
Searching associations in DataMapper
One of the first things you discover when you start playing with DataMapper is how to specify conditions when searching a database table. This will get you all the chocolate biscuits:
Biscuit.all(:chocolate => true)After I’d read some of the docs I hoped I might be able to use a similar approach to search my associations. Given that a packet has_many biscuits I hoped I’d be able to do something like this:
packet.biscuits(:broken => true)I was wrong, and you’d probably only expect that to work if (like me) you hadn’t done much with DataMapper yet. Still, you might.
In the current version (0.3.0) you do it like this:
Biscuit.all(:packet_id => packet.key, :broken => true)That’s fine. I dare say associations will grow the ability to be searched in due course, but in the meantime, maybe that’ll help clarify it for somebody…
If you’re interested in DataMapper (and merb?) then you might want to check out the open source book on the subject: Life On The Edge With Merb, DataMapper & RSpec.