Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotreload error NameError(uninitialized constant Devise::Models::TwoFactorAuthenticatable::AttrEncrypted) #203

Open
neohunter opened this issue Nov 14, 2021 · 1 comment
Labels
< v5 v5 of devise-two-factor is a major change to support Rails 7 and beyond

Comments

@neohunter
Copy link

two factor is working perfect, but each time I do a change in my rails app (and server do a hotreload) I start receiving this error:

There was an exception - NameError(uninitialized constant Devise::Models::TwoFactorAuthenticatable::AttrEncrypted)
/usr/local/bundle/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `block in load_missing_constant'
/usr/local/bundle/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
/usr/local/bundle/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `rescue in load_missing_constant'
/usr/local/bundle/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `load_missing_constant'
/usr/local/bundle/gems/devise-two-factor-4.0.1/lib/devise_two_factor/models/two_factor_authenticatable.rb:13:in `block in <module:TwoFactorAuthenticatable>'
/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/concern.rb:122:in `class_eval'
/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/concern.rb:122:in `append_features'
/usr/local/bundle/gems/devise-4.6.2/lib/devise/models.rb:105:in `include'
/usr/local/bundle/gems/devise-4.6.2/lib/devise/models.rb:105:in `block (2 levels) in devise'
/usr/local/bundle/gems/devise-4.6.2/lib/devise/models.rb:89:in `each'
/usr/local/bundle/gems/devise-4.6.2/lib/devise/models.rb:89:in `block in devise'
/usr/local/bundle/gems/devise-4.6.2/lib/devise/models.rb:116:in `devise_modules_hook!'
/usr/local/bundle/gems/devise-4.6.2/lib/devise/models.rb:86:in `devise'
/app/app/models/employee.rb:4:in `<class:Employee>'

It only happens when a file is changed, if I restart server everything works normally, any ideaS?

@neohunter neohunter changed the title hotreload error hotreload error NameError(uninitialized constant Devise::Models::TwoFactorAuthenticatable::AttrEncrypted) Nov 14, 2021
@enerfip-dev
Copy link

enerfip-dev commented Jun 16, 2022

Hi!

When hot reloading your models in dev mode, AttrEncrypted module is removed from constants but it is not reloaded, that's how I understand the issue.

This could be fixed in the gem adding require "attr_encrypted" in the gem ( at the top of devise-two-factor/lib/devise_two_factor/models/two_factor_authenticatable.rb )

In the meantime you can just add the attr_encrypted gem in your app Gemfile it should fix the problem (it did for me)

@bsedat bsedat added the < v5 v5 of devise-two-factor is a major change to support Rails 7 and beyond label Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
< v5 v5 of devise-two-factor is a major change to support Rails 7 and beyond
Projects
None yet
Development

No branches or pull requests

3 participants