Excluding Modules
By default, almost all of the Devise modules are included:
You may not want all of these features enabled in your app. That's OK! You can mix and match to suit your own unique style.
The following example shows how to disable email confirmation.

Example: disable email confirmation

Just list the devise modules that you want to include before including the DeviseTokenAuth::Concerns::User model concern.
1
# app/models/user.rb
2
class User < ActiveRecord::Base
3
4
# notice this comes BEFORE the include statement below
5
# also notice that :confirmable is not included in this block
6
devise :database_authenticatable, :recoverable,
7
:trackable, :validatable, :registerable,
8
:omniauthable
9
10
# note that this include statement comes AFTER the devise block above
11
include DeviseTokenAuth::Concerns::User
12
end
Copied!
Some features include routes that you may not want mounted to your app. The following example shows how to disable OAuth and its routes.

Example: disable OAuth authentication

First instruct the model not to include the omniauthable module.
1
# app/models/user.rb
2
class User < ActiveRecord::Base
3
4
# notice that :omniauthable is not included in this block
5
devise :database_authenticatable, :confirmable,
6
:recoverable, :trackable, :validatable,
7
:registerable
8
9
include DeviseTokenAuth::Concerns::User
10
end
Copied!
Now tell the route helper to skip mounting the omniauth_callbacks controller:
1
Rails.application.routes.draw do
2
# config/routes.rb
3
mount_devise_token_auth_for 'User', at: 'auth', skip: [:omniauth_callbacks]
4
end
Copied!
Last modified 3yr ago