LiveTree problem: non-AR model

Damaris Fuentes
Mon, 02 Jul 2007 19:26:32 -0000

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? :(

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