2013-02-28 59 views
0

我有一個有兩個關係的模型。使用限制屬性渲染has_many關聯的Rabl問題

model.rb

has_many :items 
has_many :top_items, :class_name => "Item", :limit => 3 

所以在頁面渲染JSON時指數一樣,我只希望得到top_items。但是Rabl似乎並不知道這一點。它只是彈出我擁有的每一件物品,而不是3.下面是我的拉鍊代碼

child :top_items do |top_item| 
    attributes :id, :name 
end 

任何想法?

回答

0
If you eager load an association with a specified :limit option, it will be 
ignored, returning all the associated objects 

所以不可能從has_many關聯限制子尺寸。