On 4 May 2008, at 23:58, Stedwick wrote:
>
> 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">]
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---