devise-jwt: Error with JWTBlackList in rails 6
Hi,
Following the readme file to create a JWTBlackList results into an error.
uninitialized constant User (call 'User.connection' to establish a connection)::JWTBlacklist (NameError) Did you mean? JwtBlacklist
Expected behavior
No error.
Actual behavior
Throws error
`<class:User>': uninitialized constant User (call 'User.connection' to establish a connection)::JWTBlacklist (NameError) Did you mean? JwtBlacklist
Steps to Reproduce the Problem
- Create a new rails app
- Install Devise
- Install Devise-jwt
- Create JWTBlacklist model (jwt_blacklist.rb) and migration
- Add the following to User model (user.rb)
devise :database_authenticatable,
:jwt_authenticatable, jwt_revocation_strategy: JWTBlacklist
Debugging information
devise-jwt versions 0.5.9 and 0.6.0
rails version 6.0.0
Solutions
Downgrade to 5.2
Downgrading config.load_defaults 6.0 to 5.2.
Rename filename of JwtBlacklist model
renaming filename of JwtBlacklist model fromjwt_blacklist.rb to j_w_t_blacklist.rb.
Rename JwtBlacklist model
Renaming model from JwtBlacklist to JwtBlacklist
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 15 (6 by maintainers)
There is no more Blacklist, now it’s Denylist.
Ok, it is because of
config.load_defaults, which in the fixture app are not set to 6.0. I’ll upgrade the fixture app when I find the time or someone submits a PR. About the documentation, it is fixed in master. Thanks for reporting.Hey @A-Boudi , thanks for reporting.
I haven’t used Rails for a while. Probably it has changed inference rules in 6.0. What about if you just name the model
JwtBlacklistinstead ofJWTBlacklist? I guess this way you won’t have to downgradeload_defaultsnor rename the file.