Book Image

Learning Devise for Rails

By : Giovanni Sakti, Hafiz Badrie Lubis, Nia Mutiara
Book Image

Learning Devise for Rails

By: Giovanni Sakti, Hafiz Badrie Lubis, Nia Mutiara

Overview of this book

<p>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).</p> <p>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.</p> <p>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.</p> <p>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.</p>
Table of Contents (12 chapters)

Customizing Devise actions and routes


We have learned all the basic features that are commonly used in an application. Some of them are minimally customized and some of them are used as is. Maybe now is the time for you to wonder, "What if I want to customize Devise's actions, so that I can inject extra codes to do anything I want?" So, let's step forward to customize Devise's actions.

Technically, to perform action customizations, we need to create a controller that inherits Devise's controllers. It would be wise if you have a look at all of Devise's controllers first before we start this part, as shown at https://github.com/plataformatec/devise/tree/master/app/controllers/devise. So, when you start making some customizations, you will understand why you do it that way. However, I'm not going to tell you about the best practices of these customizations; I will only tell you the basics of performing the customizations. Therefore, what you will see in these examples are the instructions about...