Reputation: 76880
i'm using Single Table Inheritance in ruby on rails to model various animals. So i have a base Animal Class and then i have various subclasses in the models/animal folder.
When the user creates an animal, i want to show a select of the various animal types which allows the user to choose a "valid" animal ( which means one animal for which a class exists ).
How can i do this?
Upvotes: 0
Views: 66
Reputation: 1183
Your two choices are
Animal
.subclasses
lists all direct subclasses.Animal
.descendants
returns all subclasses regardless of level.Upvotes: 1