我有 - 我认为 - 是一个简单的问题。这是我的代码:
class Fruit < ActiveRecord::Base
end
class Apple < Fruit
end
class Kiwi < Fruit
end
假设我正确设置了所有 STI,并且表中有多种类型的 Apple 和 Kiwi 记录。从这里...
fruits = Fruit.find(:all)
...我如何从 fruits 数组中返回一组只是 Apples 的数组?
我有 - 我认为 - 是一个简单的问题。这是我的代码:
class Fruit < ActiveRecord::Base
end
class Apple < Fruit
end
class Kiwi < Fruit
end
假设我正确设置了所有 STI,并且表中有多种类型的 Apple 和 Kiwi 记录。从这里...
fruits = Fruit.find(:all)
...我如何从 fruits 数组中返回一组只是 Apples 的数组?