Creating a user token with Devise for other uses except log in into the system

Problem

You are using Devise in your rails application, and you want to have a token for authenticating an API call, but you don’t want to use the default authentication token so that.
The purpose of doing something like that is that you don’t want the application to have the same authentication rights as the devise authentication tokens.

Solution

Add the field to your user model (ie app_token).

On your user model create the following:

class User < ActiveRecord::Base

before_create :create_app_token
...
private
def create_app_token
  self.app_token = Devise.friendly_token
end