motor-admin-rails icon indicating copy to clipboard operation
motor-admin-rails copied to clipboard

Models are becoming subclasses of themselves

Open jpatters opened this issue 1 year ago • 1 comments

Something in this project is causing rails model classes to become subclasses of themselves during runtime. Even just loading the motor admin list page for a model was wreaking havoc in our system.

This is a really weird one and the only thing I have to prove it is a (somewhat) bug that it surfaced in rolify. The model in question was using resourcify and generating bad queries after simply loading the list page for the model in motor admin.

The bad queries were coming from here https://github.com/RolifyCommunity/rolify/blob/master/lib/rolify/adapters/active_record/resource_adapter.rb#L13-L26 because klasses had the same class multiple times (ie. ['Organization', 'Organization']) and the only way I can see that can happen is if a class is a subclass of itself (see https://github.com/RolifyCommunity/rolify/blob/master/lib/rolify/adapters/base.rb#L27-L29).

I initially thought this might be a bug in the rails class dependency tracking, however the issue persisted after upgrading to rails 7.1 and ruby 3.1 where they use the new ruby builtin Class.subclasses instead of their own tracking.

For now, I've had to remove motor admin from our project.

jpatters avatar Jan 20 '24 13:01 jpatters

This issue is breaking multiple rails apps using Motor admin that I'm aware of.

chrisdmacrae avatar Mar 13 '24 22:03 chrisdmacrae