I’ve been futzing with the goodness that is Merb lately. It’s nifty. Really nifty. The documentation is pretty rough though. I’ll be posting some of my discoveries here. Maybe it will help someone who, like me, was a tad lost early on.
One of the first things that confused me was migrations. Merb has
script/generate just like Rails, but
script/generate --help didn’t list a generator for migrations. When I attempted to generate a migration, I was promptly greeted with this pleasantness:
$ script/generate migration CreateUsers Started merb_init.rb ... Loading Application... Compiling routes.. Loaded DEVELOPMENT Environment... Couldn't find 'migration' generator
Turns out that Merb doesn’t support databases by default. The Merb-specific ActiveRecord plugin has to be installed and switched on before migrations become available.
(There are several ORM plugins to choose from as documented in the README, but I’ve had very little success getting the others to work so far.)
Generate your Merb project:
sudo gem install merb merb my_project cd my_project
Install the ActiveRecord plugin thusly:
sudo gem install merb_activerecord
Now open up
config/dependencies.rb and uncomment the following line:
The first time you run
script/generate after doing this, you’ll get:
Started merb_init.rb ... No database.yml file found in my_project/config. A sample file was created called database.sample.yml for you to copy and edit.
config/database.yml and customize as needed. (Don’t forget to create the test and development databases.)
Now generate your first migration:
script/generate migration CreateUsers
And you’re off to the races.