avo icon indicating copy to clipboard operation
avo copied to clipboard

Issues with load and reload

Open pmackay opened this issue 2 years ago • 2 comments

Context

As first mentioned in this thread, I am trying to understand a loading conflict between Avo and the schema method provided by dry-rails (via dry-schema). It is showing

undefined method `schema' for FooController:Class

where FooController would be the 1st controller in my app that uses the schema method.

This appears to happen when both loading and reloading Avo views. It does not happen on any other views in the app. I found this post and improved it for initial load by applying tip 7 and adjusting avo.rb to have all the Zeitwerk code after the Avo module definition. If this change sound reasonable, could it be applied?

If an Avo Resource file is modified and the view reloaded, it still hits the problem above. I assume this is because the reload behaviour is not the same as load and the dry-rails railties are not re-run (have asked for insights on that here). Any other ideas about why this might be an issue with Avo? I was also wondering why loader.eager_load is needed in avo.rb?

System configuration

Avo version: 2.11.0

Rails version: 7.0.3.1

Ruby version: 6.1

License type (Community or Pro): Community (testing Pro)

Screenshots

pmackay avatar Jul 24 '22 15:07 pmackay

adjusting avo.rb to have all the Zeitwerk code after the Avo module definition. If this change sound reasonable, could it be applied?

I don't feel comfortable doing that. It's just not the recommended way of doing things.

Any other ideas about why this might be an issue with Avo?

I'm not sure this is "an issue with Avo".

Can you re-create this in a new app and post the repo here?

Re-creating this would ensure this manifests itself because dry-rb and/or avo, and not the application internals, and would be the best way to develop and test a fix.

Thank you!

adrianthedev avatar Jul 26 '22 10:07 adrianthedev

This issue has been marked as stale because there was no activity for the past 15 days.

github-actions[bot] avatar Aug 11 '22 03:08 github-actions[bot]

Hey @pmackay do you have any updates on this issue? Have you managed to get around it/fix it?

Thanks!

adrianthedev avatar Aug 24 '22 11:08 adrianthedev

Yes, for now I've got around it by adjusting how dry-rails is loaded. Will update this if I put together a simple example app.

pmackay avatar Aug 30 '22 05:08 pmackay