Friday, January 4, 2008

Merbful Authentication is Born

Hooray... The initial release of merbful_authentication is cooked. It took a bit longer than I thought it would, mainly thanx to my unfamiliarity with test_unit. Well, that and I was away over the christmas holidays.

At the moment there is support for Datamapper and Activerecord ORM's. Hopefully Sequel will follow soon.

How to get it

The gem has been released on rubiforge, so the usual should do the trick
sudo gem install merbful_authentication
If you want source with that.

git clone git:// merbful_authentication.git
git checkout -b local/merbful_authetication origin/merbful_authentication
svn co svn://
From either of these you can package and install the gem
rake package
sudo gem install pkg/merbful_authentication-0.1.0.gem


It has the same usage as restful_authentication, without the stateful stuff. So (from README)
To use:

./script/generate authenticated user sessions \

The first parameter specifies the model that gets created in signup
(typically a user or account model). A model with migration is
created (if migrations are available), as well as a basic controller with the create method.

The second parameter specifies the sessions controller name. This is
the controller that handles the actual login/logout function on the

The third parameter (--include-activation) generates the code for a
Mailer and the required support code. Don't forget to setup your mailer for this.

Required Setup

Unfortunately there is some setup required. At the moment, some named routes are required. You can set these up in you config/router.rb
      r.resources :users
r.match("/login").to(:controller => "Sessions", :action => "create").name(:login)
r.match("/logout").to(:controller => "Sessions", :action => "destroy").name(:logout)
r.match("/users/activate/:activation_code").to(:controller => "Users", :action => "activate").name(:user_activation)
That last one is only required if you include activation. Don't forget to setup your mailer configs if your using it too.

Also, you need to have merb_helpers installed. This is for the form generation stuff. In config/dependencies.rb
dependency "merb_helpers"
All crit, comments, bug reports, patches are welcome. Patches are more welcome of course ;)

Update: You will need to install merb and merb_helpers from trunk until the official 0.5 gem for merb comes out.