0
我有一個對象Item
可以是ItemType
之一。該ItemType
有一個attribute
這是true
或false
。使用相關模型屬性返回對象
Class Item
belongs_to :item_type
end
Class ItemType
has_many :items
end
目前,我只是抓住以通常的方式最後x
對象:
latest_items = Item.last(x)
現在,我需要返回的x
Items
一個列表,其中ItemType
有attribute
設爲true
,像這樣(僞):
latest_items = Item.last(x).where(Item.item_type.attribute = "true")
這是R中很容易實現苦惱的?現在看來似乎應該是簡單的,但我四處摸索,無法找到解決方案
完美工作很容易做到這一點 - 非常感謝 – 2013-02-24 20:53:55
不客氣: ) – 2013-02-24 20:54:32