user1007998
user1007998

Reputation: 3

Has_many for different classes

Here is the thing.

I'm working on a web game just for learning and I have this problem.

I have a Character who has many items, but the items can be equipable_items or usable_items (both from different clases).

Is there a way to have a has_many in my Character class to have a bag of items of both clases together?

Upvotes: 0

Views: 257

Answers (1)

Claw
Claw

Reputation: 767

Yes, check out Single Table Inheritance. You can do a has_many association to the parent class.

EDIT: Also check out the Single Table Inheritance section in the API documentation.

Upvotes: 1

Related Questions