One of the popular ways to authenticate users in Restful services is to use a token. You can provide a temporary or permanent token (key) to a user and the token is provided in each request.
HTTP Basic Authentication uses a “username/password” pair for authentication. Client needs to send a username and password as a base64 encoded string in the header.
You can use the built-in “has_secure_password” feature for authentication. But there are many 3rd party gems that you can use very easily. I will talk about the one of the popular gems : “Devise”
Rails 3.1 includes the built-in authentication feature called “has_secure_password“. It is pretty easy to setup and customize for your needs.
The flash is very useful to show the quick message in a view. Bootstrap include “alert-xxx” classes to show various types of messages. Let’s see how we can use together.