Hi you all, I’m trying to use LiveTree with a non-AR model. As a trial,
I’ve written this model, that may be wrong. It just generates nodes.
class Elemento
attr_reader :nombre
attr_reader :id
attr_reader :parent
def initialize(value,id,parent)
@nombre = value
@id = id
@parent = parent
end
def self.find_root()
elem = Elemento.new(“Raiz”,0,nil)
elem
end
def children
children_array = []
i=1
for i in 1…4
children_array << Elemento.new(“Child”+i.to_s(),i,
self.find_root())
i=i+1
end
return children_array
end
end
On the other hand, my controller is:
live_tree :prueba_tree, :model => :elemento, :get_item_name_proc =>
Proc.new { |item| item.nombre }
def index
@root_prueba = Elemento.find_root()
end
However, even though in the view the root with the 4 children appears,
when click on any of them I get:
LiveTreeError: could not get data from server. When I click on a child,
the javascript alert does not print the name (just print “undefined”).
Any ideas?