HABTM Association with STI model

Is there a better way to do this? It looks really ugly!
http://pastie.org/1640550

Are Facility and Unit really both types of GenericUnit? What do they
have in
common? Do they really need the same parent class?

Sorry if this feel as an ‘up’, but I felt I needed to provide a more
thorough explanation about what I want to accomplish.

I’m developing a game set on Star Wars universe. On this game, I’ll have
Squadron that can buy Units to compose Fleets, provide they can (check
with
a habtm association between Squad and Unit).

But we now need an extra layer of complexity upon this. We have a new
kind
of Unit called Facility, which will produce a kind of Unit. I am
creating a
new class for Fleets composed of Facilities as well.

So, Squad can have Fleets and FacilityFleets (has_many for both), and
HABTM
on Units and Facilities. What I’ve come up so far is:

I have a GenericUnit which Unit and Facility inherits from, and a
GenericFleet which Fleet and FacilityFleet inherits from. My problem is
that
I don’t know how to set up these relationships. I’ve stuck on the
GenericUnit/Unit/Facility problem. I’ve kinda solved this as showed
here:
http://pastie.org/1640550. But this doesn’t look like the right way to
solve
this. I’m pretty sure there is a smarter way of doing this.

Thanks for your help!

Thanks for the reply!

And yeah, they are. GenericUnit was actually created to handle the
similarities, after we thought of the Facility type. They can both be
captured, and costs money, are looked upon at when registering attacks,
etc.

Code is on GitHub - lunks/wargame: CIMF Wargame, if you’d like to take a
look.