本文介绍了无法自动加载常量JWTBlacklist,需要使用/home/sourabh/dev/celebration/app/models/jwt_blacklist.rb进行定义(LoadError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的user.rb模型包含:

my user.rb model contains:

class User < ApplicationRecord

  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable,
         :confirmable, :lockable, :timeoutable, :omniauthable,
         :jwt_authenticatable, jwt_revocation_strategy: JWTBlacklist

  def send_devise_notification(notification, *args)
    devise_mailer.send(notification, self, *args).deliver_later
  end
end

我正在使用devise-jwt gem登录我的Rails api.

I am using devise-jwt gem to signin for my rails api.

我的JWTBlacklist.rb模型包含:

my JWTBlacklist.rb model contains:

class JwtBlacklist < ApplicationRecord
  include Devise::JWT::RevocationStrategies::Blacklist

  self.table_name = 'jwt_blacklist'
end

推荐答案

您的User类正在寻找JWTBlacklist,但是您的文件正在定义JwtBlacklist.您需要更改其中一个以匹配另一个.

Your User class is looking for JWTBlacklist, but your file is defining JwtBlacklist. You need to change one of those to match the other.

这篇关于无法自动加载常量JWTBlacklist,需要使用/home/sourabh/dev/celebration/app/models/jwt_blacklist.rb进行定义(LoadError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 21:10