How to return children objects?
Posted
by keruilin
on Stack Overflow
See other posts from Stack Overflow
or by keruilin
Published on 2010-04-12T21:55:49Z
Indexed on
2010/04/12
22:03 UTC
Read the original article
Hit count: 398
I have -- what I think -- is a simple question. Here's my code:
class Fruit < ActiveRecord::Base
end
class Apple < Fruit
end
class Kiwi < Fruit
end
Assume that I have all the STI setup correctly, and there are multiple types of Apple and Kiwi records in the table. From here...
fruits = Fruit.find(:all)
...how do I return an array of just Apples from the fruits array?
© Stack Overflow or respective owner