TrestleAdmin / trestle-auth

Authentication plugin for the Trestle admin framework
https://trestle.io
GNU Lesser General Public License v3.0
52 stars 23 forks source link

Generator fails when integrating with Devise #51

Open gutschi opened 6 months ago

gutschi commented 6 months ago

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:

spohlenz commented 4 months ago

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?