Wednesday, October 10, 2007

Enabling Sessions on Merb

I just fired up merb for a project and i realised, I didn't know how to turn on sessions. It turns out its easy.

In merb.yml, to use the data_mapper sessions support include the line

:session_store: data_mapper

Alternatively you can use memory, cookie, memcache or a custom one from an ORM plugin.

Usually when using an ORM plugin a migration is required. To find out what's available use

rake -T

At the moment the datamapper plugins rake tasks are broken and don't generate migrations. You can still use the datamapper sessions, just start merb and if the table is missing, it will be created.

Easy :)