O'Reilly logo

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

Learning Devise for Rails

Book Description

In choosing a fully-featured user sign-in system for your Rails web applications you can’t do better than Devise. And there’s no better book for learning Devise than this superb step-by-step tutorial.

  • Use Devise to implement an e-mail-based sign-in process in a few minutes
  • Override Devise controllers to allow username-based sign-ins, and customize default Devise HTML views to change the look and feel of the authentication system
  • Test your authentication codes to ensure stability

In Detail

There are numerous ways of implementing user sign-ins on your Rails web applications. Of those different ways, using Devise is one of the most popular, quick and flexible way to get user sign-ins working. It is extensible and plays well with other gems such as CanCan (for user privileges) and OmniAuth (for Facebook and Twitter sign-ins).

A hands-on, all-in-one guide that gives you step-by-step instructions along with code examples to implement authentication systems in your application. This book will help you to implement various schemes of authentication systems including authorization and remote authentication, using Devise.

Helping you make your Rails applications more accessible and user-friendly; this book explains how to implement user sign-ins in Rails. It will also show you how to customize user authentication pages, such as sign-in, sign-up, forgot password, and account details, by making use of existing Devise views. In addition, you will learn about facilitating complex privilege rules using the CanCan gem. Finally, you will discover how to make sure your authentication codes work as expected by using integration tests.

You will learn all you need to know to create user email and social network sign-ins quickly, to customize user sign-in-related views, and implement complex privileges, as well as to ensure the stability of your authentication codes by testing them.

Table of Contents

  1. Learning Devise for Rails
    1. Table of Contents
    2. Learning Devise for Rails
    3. Credits
    4. About the Authors
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Devise – Authentication Solution for Ruby on Rails
      1. Devise modules
      2. Installation
      3. Run your first application with Devise
      4. Summary
    9. 2. Authenticating Your Application with Devise
      1. Signing in using authentication other than e-mails
      2. Updating the user account
      3. Signing up the user with confirmation
      4. Resetting your password
      5. Canceling your account
      6. Customizing Devise actions and routes
      7. Customizing your Devise layout
      8. Integrating Devise with Mongoid
      9. Summary
    10. 3. Privileges
      1. CollabBlogs – a web application for collaborative writing
      2. Advanced CanCan usages
        1. Defining rules using SQL
        2. Simplifying authorization checks on controllers
        3. Ensuring abilities' correctness
          1. Testing
          2. Debugging
      3. Summary
    11. 4. Remote Authentication with Devise and OmniAuth
      1. Remote authentication
      2. OmniAuth
      3. Implementing remote authentication in our application
        1. Preparing your application
        2. Remote authentication using Twitter
          1. Registering our application at the Twitter developer site
          2. Configuring OmniAuth for authentication using Twitter
        3. Remote authentication using Facebook
          1. Registering our application at the Facebook developer site
          2. Configuring OmniAuth for authentication using Facebook
      4. Summary
    12. 5. Testing Devise
      1. The sign-up test
      2. The user update test
      3. The user deletion test
      4. The sign-in test
      5. The Remote authentication test
      6. Summary
    13. Index