这句话b.followees_by_type("biscuit")
返回类似:
=> [#<Biscuit _id: 4fdf5aa11d41c829ea000020, _type: "Biscuit", created_at: 2012-06-18 16:43:13 UTC, title: "biscuit biscuit", is_complete: true>, #<Biscuit _id: 4fdf5aa11d41c829ea000021, _type: "Biscuit", created_at: 2012-06-18 17:40:10 UTC, title: "biscuit2 biscuit2", is_complete: true> ]
可以退回一个或多个饼干。
我想在实例变量@biscuits
中添加,我从这个块的每个循环中得到的所有饼干:
boards.each do |b|
b.followees_by_type("biscuit")
end
我该怎么做?
答案 0 :(得分:1)
@biscuits = boards.flat_map {|b| b.followees_by_type('biscuit') }