Module LiveTree::ClassMethods
In: live_tree.rb

Methods

live_tree  

Public Instance methods

Sets up this controller to serve data for a LiveTree.

Arguments:

  • name - the tree’s name.
  • options - may contain:
    • :model - name of the model to use for retrieving data (symbol).
    • :model_class_name - name of the model’s class, incase it can’t be inferred (string)
    • :find_item_proc - proc object which, when called with an ID, returns the item with that ID. If not specified, the model’s find method is used.
    • :get_item_id_proc - proc object which, when called with an item, returns the id of the item to display. If not specified, the item’s id is retrieved using the object’s id attribute. This parameter will only be useful if you also specify :find_item_proc.
    • :get_item_name_proc - proc object which, when called with an item, returns the name of the item to display. If not specified, the item’s name is retrieved using the object’s name attribute.
    • :get_item_children_proc - proc object which, when called with an item, returns the item’s children. If not specified, the item’s children attribute is used.
    • :get_item_parent_proc - proc object which, when called with an item, returns the item’s parent. If not specified, the item’s parent attribute is used

Either one of :model, :model_class_name, or find_item_proc must be specified.

This example sets up this controller to serve data for a tree with name family_tree, that uses the person model to get data:

    class FamilyController < ApplicationController
      live_tree :family_tree, :model => :person
    end

A data retrieval method is magically created that is named <name>_live_tree_data (e.g. family_tree_live_tree_data)

[Validate]