excid3 / madmin

A robust Admin Interface for Ruby on Rails apps

Home Page:https://github.com/excid3/madmin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Zeitwerk::NameError in Madmin::DashboardController#show

timmyd87 opened this issue · comments

Hi team,

I ran the install command on a semi changed jump start pro app. It builds out all the resources and seems to get the routes right however i get the error 'Zeitwerk::NameError in Madmin::DashboardController#show' saying it expected 'to define constant Resources::AccountInvitationResource, but didn't' - account invitation is the example here. Adding 'Resources::' to the class name just throws another error.

Any clues? A little wary of running install again unless there are other options to pass in?

Screen Shot 2021-04-18 at 6 53 28 pm

I haven't tested this on Jumpstart Pro yet, but I will soon and will get this fixed. 👍

I have a similar error on jumpstart github. When I first start foreman and go to the page I get this error:

expected file /Users/xxx/Documents/Sites/madmintest/app/madmin/resources/action_text/rich_text_resource.rb to define constant ActionText::RichTextResource, but didn't

If i hit refresh it loads fine and doesn't come up again. Any ideas on what this is?

@spacerobotTR can you paste me the contents of the rich_text_resource.rb file?

I just verified it generated it fine for the test dummy app in the madmin repo, so not sure why yours would be different.

@timmyd87 I don't know why, but I started getting that error too. If I refresh the page, it resolves itself immediately without any changes. Strange.

And yet, I can enable the logger and it loads just fine after a reboot.

Zeitwerk@rails.main: constant PostResource loaded from file /Users/chris/code/madmin/test/dummy/app/madmin/resources/post_resource.rb

Possibly related to the eager_load paths that we're adding to the Rails app to make app/madmin/resources work.

Thanks @excid3 for taking a look. I can confirm if i refresh the screen it will load without any changes. If you have multiple resources you have to refresh until it's moved through each resource before it shows without error.

If you have multiple resources you have to refresh until it's moved through each resource before it shows without error.

Interesting, I did not have that issue. For me, it was only the PostResource but everything else loaded fine.

And then coming back after a few hours, it's not doing it again. I wonder if there is something being cached with bootsnap or something? Maybe try clearing the tmp directory?

If anyone can find a reliable way to reproduce this, let me know.

It skips them because you don't have ActionMailbox or ActionText installed.

I just rewrote this to read through the files instead of using eager_load. Should be more reliable and doesn't require loading your entire application. 👍