Re: LiveTree problem: non-AR model

Damaris Fuentes
Tue, 03 Jul 2007 15:32:19 -0000

Well, the problem was that I wasn''t stating which are the exact
children
of every node. The solution could be:

def initialize(value,id,parent)
    @name = value
    @id = id
    @parent = parent
    @children = []
  end

def self.find_root()
  @@root = Elemento.new("Root",0, nil)
  @@child1 = Elemento.new("Child 1",1,@@root)
  @@child2 = Elemento.new("Child 2",2,@@root)
  @@child3 = Elemento.new("Child 3",3,@@root)
  @@child4 = Elemento.new("Child 4",4,@@root)
  @@child21 = Elemento.new("Child 21",21,@@child2)
  @@child22 = Elemento.new("Child 22",22,@@child2)
  @@child23 = Elemento.new("Child 23",23,@@child2)
  @@child24 = Elemento.new("Child 24",24,@@child2)

  @@root.children = [@@child1,@@child2,@@child3,@@child4]
# @@child2.children = [@@child21,@@child22,@@child23,@@child24]
  @@root
end

However, you will see a line in comments. If I add this line, the same
problem as the previous post appears. And now I am stating the parent
and the children of every node. What I am doing wrong?

Thanks.

--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---