在红宝石块中:
user.trips.each { |trip| trip.pickedpost.user }
如何使代码返回一组用户?
如果我运行块
user.trips.each { |trip| puts trip.pickedpost.user }
irb 节目
#<User:0x007fd1ab9e2148>
#<User:0x007fd1aacf3dd8>
=> [#<Trip id: 18, pickedpost_id: 25, volunteer_id: 33, created_at: "2012-05-14 23:28:36", updated_at: "2012-05-14 23:28:36">, #<Trip id: 20, pickedpost_id: 20, volunteer_id: 33, created_at: "2012-05-15 00:12:39", updated_at: "2012-05-15 00:12:39">]
该块返回一个行程对象数组,这不是我想要的。
如何使块返回用户数组?
谢谢