You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are certain setups that will try to do loading for us (e.g. Rails, or more specifically, Zeitwerk) which infer that if we have a webauthn.rb file, it will define a Webauthn module (not WebAuthn, as it currently does).
I noted that a Sidekiq worker from my Rails app was raising a NameError (uninitialized constant Webauthn). I could fix this by appending require: false to my Gemfile entry for this gem and manually calling require 'webauthn' in the places where it was needed (e.g. initializer, controllers).
Note: In my app I also have controllers such as Webauthn::CredentialsController in app/controllers/webauthn/credentials_controller.rb, and this could have been the cause of my particular error. Nevertheless, I think we could all benefit from sticking to a consistent naming from this gem.
The text was updated successfully, but these errors were encountered:
Idiomatic Rails applications only issue require calls to load stuff from their lib directory, the Ruby standard library, Ruby gems, etc. That is, anything that does not belong to their autoload paths, explained below.
Within an autoload path, file names must match the constants they define as documented here.
By default, the autoload paths of an application consist of all the subdirectories of app that exist when the application boots ---except for assets, javascript, and views--- plus the autoload paths of engines it might depend on.
Yeah, I also believe it had to do with my app's Webauthn module.
Even if I still feel that following a more standard naming convention (i.e. webauthn.rb declaring Webauthn and web_authn.rb declaring WebAuthn) could be clearer, it's not a huge thing, so feel free to close this issue if you want (I'm not closing it in case it is something you want to have in the roadmap or would accept a PR about).
There are certain setups that will try to do loading for us (e.g. Rails, or more specifically, Zeitwerk) which infer that if we have a
webauthn.rb
file, it will define aWebauthn
module (notWebAuthn
, as it currently does).I noted that a Sidekiq worker from my Rails app was raising a
NameError (uninitialized constant Webauthn)
.I could fix this by appendingrequire: false
to my Gemfile entry for this gem and manually callingrequire 'webauthn'
in the places where it was needed (e.g. initializer, controllers).Note: In my app I also have controllers such as
Webauthn::CredentialsController
inapp/controllers/webauthn/credentials_controller.rb
, and this could have been the cause of my particular error. Nevertheless, I think we could all benefit from sticking to a consistent naming from this gem.The text was updated successfully, but these errors were encountered: