Acts_as_tree -- getting children IDs?

I’m having trouble getting all the IDs of the children of my
acts_as_tree group.

child.id seems to return the entire object.

for child in g.children
child.id
end
=> [#<Group id: 2, name: “Campaign Admin”, parent_id: 1, affiliate_id:
nil, created_at: “2008-05-04 22:21:16”, updated_at: “2008-05-04
22:21:16”, permission: “campaigns”>, #<Group id: 4, name: “Ideas
Admin”, parent_id: 1, affiliate_id: nil, created_at: “2008-05-04
22:22:05”, updated_at: “2008-05-04 22:22:05”, permission: “ideas”>,
#<Group id: 3, name: “User Admin”, parent_id: 1, affiliate_id: nil,
created_at: “2008-05-04 22:21:39”, updated_at: “2008-05-04 22:21:39”,
permission: “users”>]

Any ideas? Thanks!

On 4 May 2008, at 23:58, Stedwick wrote:

nil, created_at: “2008-05-04 22:21:16”, updated_at: “2008-05-04
22:21:16”, permission: “campaigns”>, #<Group id: 4, name: “Ideas
Admin”, parent_id: 1, affiliate_id: nil, created_at: “2008-05-04
22:22:05”, updated_at: “2008-05-04 22:22:05”, permission: “ideas”>,
#<Group id: 3, name: “User Admin”, parent_id: 1, affiliate_id: nil,
created_at: “2008-05-04 22:21:39”, updated_at: “2008-05-04 22:21:39”,
permission: “users”>]

A for loop evaluates to the colection it iterates over. You probably
want something like g.children.collect {|child| child.id} (sometimes
people write g.children.collect &:id instead)

Fred