FOR RAILS 3.0: A newer and more current Rails authentication example app shows how to set up Rails with the Devise authentication gem. It’s got a detailed Rails authentication tutorial plus an application template that can be used to generate a starter app. It shows how to use RSpec and Cucumber for testing with Devise as well. There’s a similar example app that shows how to set up Devise for authentication with the Mongoid gem and MongoDB database for quick development without schemas or migrations.
UPDATE: Rails has advanced since this application was released in mid-2008. As of February 2010, Rails is currently at version 2.3.5 (and Rails 3 is in beta). Several Rails gems are now available that provide a turnkey authentication solution, including Authlogic, Devise, and Clearance. You can also look at Technoweenie’s restful-authentication generator. The Ruby Toolbox page for Rails Authentication shows which are most popular. I personally recommend Devise.
I’ve released an open source Rails application that provides an example of RESTful Authentication.
It provides a complete system for managing users, including sign up and verification of a new user’s email address, login with role-based access control, and a system of resetting forgotten passwords, all using a RESTful architecture.
You can easily customize the application for your own needs.
You can obtain the source code here:
It is based on recommendations from the forum discussion Restful Authentication With All the Bells and Whistles.