merb-auth beginner’s tutorial

THIS TUTORIAL IS CURRENTLY OUT OF DATE. Hassox has redone merb-auth and it is even better now. I’ll be updating this tutorial as soon as possible. 

===========

===========

===========

===========

 

(this assumes you’ve already setup merb using this tutorial or something similar)

Install the necessary gems

sudo gem install merb_has_flash
cd ~/sources
git clone git://github.com/hassox/merb-auth.git
cd merb-auth
sudo rake install

Setup init.rb and router.rb

#init.rb
 
dependencies "merb-more", "merb_helpers", "merb-assets", "dm-timestamps", "dm-validations", "merb-slices", "merb-auth", "merb_has_flash"
 
...
 
Merb::BootLoader.before_app_loads do
  Merb::Slices::config[:merb_auth][:layout] = :application
end
 
...
#router.rb
 
...
 
Merb::Router.prepare do |r|
  # Slices
  # ADD THIS FOR MERB-AUTH
  r.add_slice(:MerbAuth, :path => "", :default_routes => false) 
 
  # RESTful routes
  # r.resources :posts
  # This is the default route for /:controller/:action/:id
  # This is fine for most cases.  If you're heavily using resource-based
  # routes, you may want to comment/remove this line to prevent
  # clients from calling your create or destroy actions with a GET
  r.default_routes
 
  # Change this for your home page to be available at /
  # r.match('/').to(:controller => 'whatever', :action =>'index')
end

Comments

  1. Matt Aimonetti | September 17, 2008

    Hassox rewrote merb-auth in 2 parts, mauth and some slices. Check his mauth branch on github to get some good info what what he’s working on.

  2. scott | September 19, 2008

    Thanks Matt for the pointer. I will check that out.

  3. hassox | October 12, 2008

    Hey Scott,

    Mauth, now merb-auth is now available in the merb-more repo.

    :)

  4. scott | October 13, 2008

    awesome. thanks hassox.