trestle-auth
trestle-auth copied to clipboard
Generator fails when integrating with Devise
After installation of the gem when I run the generator it fails.
rails generate trestle:auth:install AdminUser --devise
fails with
/app/app/admin/auth/admin_users_admin.rb:1:in `<top (required)>': uninitialized constant Auth (NameError)
Trestle.resource(:admin_users, model: AdminUser, scope: Auth) do
If I remove the , scope: Auth
from the generated Trestle resource admin_users_admin.rb
everything seems to work. Not sure what the Auth
scope is supposed to do there though ...
Rails and gem versions:
- rails (7.1.3.2)
- devise (4.9.3)
- trestle (0.9.8)
- trestle-auth (0.4.4)
I've tried various things and unfortunately haven't been able to reproduce this (though I did uncover a couple of unrelated Rails 7.1 issues in the process).
My gut feel is that this is something to do with Zeitwerk -- the Auth module is an implicit module/namespace that is (or at least should be) created by having the trestle-auth resources within the app/admin/auth
folder.
I assume that you have created a Devise AdminUser
model already (otherwise I'd expect to see "uninitialized constant AdminUser"). If you are still experiencing this issue, you could please also share your versions of Ruby and Zeitwerk, as well as if you have any customized autoloading configuration?