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)
1 sudo gem install merb_has_flash 2 cd ~/sources 3 git clone git://github.com/hassox/merb-auth.git 4 cd merb-auth 5 sudo rake install
1 sudo gem install merb_has_flash
2 cd ~/sources
3 git clone git://github.com/hassox/merb-auth.git
4 cd merb-auth
5 sudo rake install
Setup init.rb and router.rb
1 #init.rb 2 3 dependencies "merb-more", "merb_helpers", "merb-assets", "dm-timestamps", "dm-validations", "merb-slices", "merb-auth", "merb_has_flash" 4 5 ... 6 7 Merb::BootLoader.before_app_loads do 8 Merb::Slices::config[:merb_auth][:layout] = :application 9 end 10 11 ...
1 #init.rb
2
3 dependencies "merb-more", "merb_helpers", "merb-assets", "dm-timestamps", "dm-validations", "merb-slices", "merb-auth", "merb_has_flash"
4
5 …
6
7 Merb::BootLoader.before_app_loads do
8 Merb::Slices::config[:merb_auth][:layout] = :application
9 end
10
11 …
1 #router.rb 2 3 ... 4 5 Merb::Router.prepare do |r| 6 # Slices 7 # ADD THIS FOR MERB-AUTH 8 r.add_slice(:MerbAuth, :path => "", :default_routes => false) 9 10 # RESTful routes 11 # r.resources :posts 12 # This is the default route for /:controller/:action/:id 13 # This is fine for most cases. If you're heavily using resource-based 14 # routes, you may want to comment/remove this line to prevent 15 # clients from calling your create or destroy actions with a GET 16 r.default_routes 17 18 # Change this for your home page to be available at / 19 # r.match('/').to(:controller => 'whatever', :action =>'index') 20 end
1 #router.rb
2
3 …
4
5 Merb::Router.prepare do |r|
6 # Slices
7 # ADD THIS FOR MERB-AUTH
8 r.add_slice(:MerbAuth, :path => "", :default_routes => false)
9
10 # RESTful routes
11 # r.resources :posts
12 # This is the default route for /:controller/:action/:id
13 # This is fine for most cases. If you’re heavily using resource-based
14 # routes, you may want to comment/remove this line to prevent
15 # clients from calling your create or destroy actions with a GET
16 r.default_routes
17
18 # Change this for your home page to be available at /
19 # r.match(‘/’).to(:controller => ‘whatever’, :action =>‘index’)
20 end
![]()
Spitfire Sky | github | archives | resume