Andrew McDonough


Restful Authentication|Rick Olsen’s restful authentication is my current preferred method for authenticating users.


Add Rick Olsen’s repository ruby script/plugin source

Install the resfulauthentication plugin ruby script/plugin install restfulauthentication

Generate the ruby script/generate authenticated user sessions —include-activation

Create the tables in the database rake db:migrate

Add the following routes to config/routes.rb map.activate ‘/activate/:activationcode’, :controller => ‘users’, :action => ‘activate’, :activationcode => nil map.signup ‘/signup’, :controller => ‘users’, :action => ‘new’ map.login ‘/login’, :controller => ‘sessions’, :action => ‘new’ map.logout ‘/logout’, :controller => ‘sessions’, :action => ‘destroy’

Now for any controllers to which you want to restrict access, add the following line: beforefilter :loginrequired

Andrew McDonough


Follow Andrew on Twitter or Connect on LinkedIn