O'Reilly logo

Learning Rails: Live Edition by Edd Dumbill, Simon St. Laurent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 14. Users and Authentication

While sessions expand your application-building possibilities, almost any interactive application that will be around for a while needs to be able to keep track of users. You might be a little startled to hear that Rails itself doesn’t include any mechanisms for tracking users, unlike most current web frameworks. That isn’t so much a failure as an opportunity for developers to create their own authentication approaches. When getting started, however, it’s probably wisest to work with the commonly used restful_authentication plug-in. (The code for this example is available in ch14/students007.)

Note

Note that the restful_authentication plug-in is based on the older acts_as_authenticated plug-in. Many applications use, and much documentation describes, acts_as_authenticated, which has similar data structures but doesn’t operate in a RESTful way.

Installation

Authentication is a complicated enough project that it’s worth fitting into a more sophisticated application, like the students and courses example. The first step toward adding authentication to it is to install the restful_authentication plug-in. From the application directory, enter:

$ script/plugin install http://svn.techno-
weenie.net/projects/plugins/restful_authentication

Warning

More recent versions of restful_authentication have moved to a different location, git://github.com/technoweenie/restful-authentication.git. Using that version, which has changed slightly from the one described here, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required