Class table inheritance

After having tried pretty much every solution out there for CTI in AR,
I’m now trying out the native postgres inheritance support. After a
couple of activerecord hacks, I have it mostly working, but am running
into some issues. The main problem seems to come when a child model
is loaded through an association which points to the parent. Code is
here: postgres cti hacks · GitHub

It seems that in some cases, activerecord queries the parent tables
attributes to determine the valid attributes instead of the child.
Sometimes calling reload brings in the actions. However, when inside
an association, it seems a different version of reload gets called
from activerecord::relation instead of activerecord::persistence.
That version of reload seems to always use the parent table.
I’ve spent a few hours inside the internals of AR, but I’m in over my
head. Any activerecord ninjas out there have any idea how I can work
around that?

And if any core team members are around, any chance of a real CTI
implementation ever making it into activerecord?
I’ve seen about a million workarounds for this, but they’re all pretty


This is all with rails 3.0.6 btw

I think your issues have to do with your use of the type column and it
triggering rails STI magic. STI is assuming all columns are defined on
the parent and will never attempt to loan column names from the child
tables. I am investigating using native postgres inheritance for a
project I’m working on, I’ll post back if I get anywhere with it.