Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Zeitwerk conventions for Refinery::Pages::Finder #3524

Merged
merged 1 commit into from
May 12, 2023

Conversation

richard-kramer
Copy link
Contributor

Regarding #3523

The issue stems from the definition of Refinery::Pages::Finder and its sibling classes (Refinery::Pages::FinderByTitle and so on). These are all defined beside each other in pages/lib/refinery/pages/finder.rb which gets required in pages/app/models/refinery/page.rb.

When reloading, zeitwerk reloads the model, which in turn loads the finder again. But because the file is named finder.rb, only Refinery::Pages::Finder gets unloaded and reloaded again. All other classes stay loaded and would be patched by the reload. But because Refinery::Pages::Finder has been reloaded and initialized again, it got a new object_id, thus triggering the superclass mismatch error.

The solution, that fixed the error, was to move all sibling-classes of Refinery::Pages::Finder into it, making them children of Refinery::Pages::Finder. Because they are only called inside Refinery::Pages::Finder itself, this should not make problems.

I am not sure, if this is the best or most elegant solution, if it introduces side effects or if there are other parts of refinery, that suffer the same issues.

@parndt parndt changed the title fix zeitwerk conventions for Refinery::Pages::Finder Fix Zeitwerk conventions for Refinery::Pages::Finder May 12, 2023
@parndt parndt changed the title Fix Zeitwerk conventions for Refinery::Pages::Finder Fix Zeitwerk conventions for Refinery::Pages::Finder May 12, 2023
@parndt parndt merged commit 5cbbd14 into refinery:main May 12, 2023
@parndt
Copy link
Member

parndt commented May 12, 2023

Thank you! 💙💛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants