Invalid single-table inheritance

Using Forest Admin along with Rails and STI, reload breaks everything.
When the Rails cache is deactivated for development purposes, declared STI systematically down the response.

Console issue:

Forest 🌳🌳🌳  Records Index error: Invalid single-table inheritance type: XXX is not a subclass of YYY

Where XXX extends YYY, and YYY extends ActiveRecord::Base

A repository reproducing the error is available here: GitHub - off-works/forest-sti. Just follow README.md instructions.

4 Likes

Hi @Off-Works , and welcome to our community :wave:

Really nice reproducible example. I just followed your README.md and I’m able to reproduce this issue. I’ll investigate this to see if I’m able to locate the origin of the issue.

Many thanks :pray:

6 Likes

HI @jeffladiray,

Did you had enough time to reproduce the problem and target the source ? Don’t hesitate to ask if you need complementary informations.

Thanks for your help :slightly_smiling_face:

Hi @Off-Works,

Thanks for your message!

The issue is still under investigation.
Here are some details to follow the resolution.

Thanks again for your patience :slight_smile:

1 Like

Hi @anon34731316 ,

There’s almost a month, we posted this problem with an associated repository. It’s quite blocking on our side …

Could you up the topic and reconsider it as soon as possible ?

Many thanks :wink:

Hello @Off-Works,

Looks like this is a known issue with hot reload in dev environment and STI.
Would will be possible for you to activate the cache?

config/environments/development.rb line 9

config.cache_classes = true

Let me know if it solves your issue :slight_smile:

Hi,

We’ve already known since the beginning that this error is relative to cache_classes parameter.
I’ve mentioned it in my first message:

When the Rails cache is deactivated for development purposes, …

Unfortunately, we just can’t disable this parameter on environment development, it is too important. :frowning_face:
It is not really a workaround to have to restart the web server each time we make code changes, just to make ForestAdmin work.

Why ForestAdmin gem doesn’t work correctly with STI classes when cache_classe is disabled? It’s clearly a big issue.

Hi @Off-Works,

Thanks for your help, the issue is well identified.

Unfortunately we don’t have the bandwidth to fix this issue in the short term.
We plan to recruit people to help us solve those kind of complex issues.

I am sorry to inform you that you’ll have to activate the cache while developing for ForestAdmin purpose if you want to have a properly working STI. Although painful, it is a valid workaround for the issue.

If this is too painful for you, another option is to fork the open-source gem and find a way to solve this issue.

Thanks for your patience.

Not sure if folks have found a workaround since… but this issue is pretty brutal. Having to toggle this on and off / restart my server in development is really frustrating. Glad I found this thread, but Forest has become way less usable since we added STI stuff to our app

Any update on this? I find myself coming back to this thread every month or so to remember how to patch over this…

Just came back here again hoping for some news :slight_smile:

Hello @Kevin_Davis,

The issue doesn’t seem to be linked to our package but to the rails livereload.
According to the official documentation : lazy loading does not work very well with an STI.
However, in the documentation, you can find a solution with an STI preloading module