rails-erd icon indicating copy to clipboard operation
rails-erd copied to clipboard

inheriting model class shows as a table

Open mathieujobin opened this issue 6 years ago • 5 comments

Hi,

I have a special use case, i don't think its handled properly.

I'm inheriting a model to have different validations but I'm not using STI

class Animal < AR::Base; end
class Dog < Animal; end

in my generated ERD, Dog shows up as a separate table. I'd like to have it as a grayed inheritance class

I'm not familiar with the code base, i don't know if this is easily fixable?

thanks

mathieujobin avatar Jul 13 '18 01:07 mathieujobin

Thanks for your gem by the way, its awesome

mathieujobin avatar Jul 13 '18 01:07 mathieujobin

@mathieujobin Interesting! I'll dig into the ActiveRecord metadata and see if I can extract this information easily.. I believe it /should/ be, but it might be a case where we need to cross-reference the #table_name against the ancestor(s) of the class.

To be clear, in your example, Dog and Animal are using the same table, but you're not using AR's STI features?

I wonder if something like what we did in voormedia/rails-erd#205 would look ok?

kerrizor avatar Sep 10 '18 20:09 kerrizor

that's right, same table, inherit one another, but no STI features

mathieujobin avatar Sep 10 '18 21:09 mathieujobin

is this a quick fix? if at least the diagram box would not be floating, and showing an inheritance line to its parent, I'd be happy

dashed box might sound good because its not a separate table.

mathieujobin avatar Sep 26 '18 01:09 mathieujobin

@mathieujobin Is this still an issue? I've been thinking about how to test this, given how much reliance we have on AR internals in our setup/teardown..

kerrizor avatar May 14 '19 17:05 kerrizor