1
我有 - 我的想法 - 是一個簡單的問題。這裏是我的代碼:如何返回子對象?
class Fruit < ActiveRecord::Base
end
class Apple < Fruit
end
class Kiwi < Fruit
end
假設我正確擁有所有的STI設置,並有多種類型的表中的蘋果和獼猴桃的記錄。從這裏...
fruits = Fruit.find(:all)
...我如何返回水果數組中的蘋果數組?