I use the acts_as_tree plugin, and I try to display a list of the
elements w group_by

in my controller
...
    companies = Company.find :all, conditions => Company.visible_by
(User.current),  :include => :parent
    respond_to do |format|
      format.html {
        @company_tree = companies.group_by {|p| p.parent || p}
      }

I have the  company ids :      [ 1, 2, 3, 4, 5, 6]
with the following tree structure :    1 children ->[ 2 , 3]    2 ->
children [4, 5, 6]    and 3 has no child

the companies.group by gives me correctly  an Hash with
[key company 1 ->  value [company 2, company 3]
key company 2 ->  value [company 4, company 5, company 6] ]

but no key company 3 ... is it because the group is empty (no
child) ...  how can I get the key company 2, with an empty array as
value ?   is it possible ?

thanks for your help
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to