janko / rodauth-rails

Rails integration for Rodauth authentication framework
https://github.com/jeremyevans/rodauth
MIT License
565 stars 40 forks source link

NameError: uninitialized constant Rodauth::BCrypt #275

Closed whysthatso closed 5 months ago

whysthatso commented 5 months ago

hey, i'm seeing this one a setup i've copied from another of my work apps.

This error happens when i actually want to create an account in a seed, or on the console.

Besides that the app boots up normally.

Where would i start debugging this, and what could this indicate?

janko commented 5 months ago

This is because Rodauth's post_configure hook isn't getting called, which requires the bcrypt gem. This is the result of only auth class being loaded (e.g. RodauthMain), without the encompassing Rodauth app. This was caused by rodauth-rails generator switching from include Rodauth::Rails.model (essentially Rodauth::Model(RodauthApp.rodauth)) to include Rodauth::Model(RodauthMain) in the account model.

You should be able to resolve the issue by replacing the Rodauth::Model(RodauthMain) declaration with Rodauth::Rails.model in your account model. Alternatively, you could require bcrypt in your app/misc/rodauth_main.rb, but I think the proposed change is more robust. I'll update the generator.

whysthatso commented 5 months ago

yep, that did it.

:tada: