AuthSlice

An user authentication slice for the Merb framework. See github.com/ctran/merb-skel for an example application that uses this slice

Installation:

> gem install merb > gem install merb-slices

To use activerecord adapter > gem install activerecord > gem merb_activerecord

To use datamapper adapter > gem install datamapper > gem install merb_datamapper

config/init.rb

# add the slice as a regular dependency dependency ‘auth-slice’

config/router.rb

# This will add the following routes /login, /logout and /signup r.slice(:AuthSlice)

# This will add the following routes /auth-slice/login, /auth-slice/logout and /auth-slice/signup r.add_slice(:AuthSlice)

# This will add the following routes /user/login, /user/logout and /user/signup r.add_slice(:AuthSlice, ‘user’) # same as :path => ‘user’

Normally you should also run the following rake task:

> rake slices:auth_slice:install

Customization/Overrides

By default, the user model class is in AuthSlice::User. To use shorter name, add this to your init.rb

Merb::Slices.config = { :user_model_class => “User” }

You can also put your application-level overrides in:

host-app/slices/auth-slice/app - controllers, models, views …

Templates are located in this order:

  1. host-app/slices/auth-slice/app/views/*

  2. gems/auth-slice/app/views/*

  3. host-app/app/views/*

You can use the host application’s layout by configuring the auth-slice slice in a before_app_loads block:

Merb::Slices.config = { :layout => :application }

By default :auth_slice is used. If you need to override stylesheets or javascripts, just specify your own files in your layout instead/in addition to the ones supplied (if any) in host-app/public/slices/auth-slice.

In any case don’t edit those files directly as they may be clobbered any time rake auth_slice:install is run.