README
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:1k
源码类别:

Ajax

开发平台:

Others

  1. acts_as_tree
  2. ============
  3. Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
  4. association. This requires that you have a foreign key column, which by default is called +parent_id+.
  5.   class Category < ActiveRecord::Base
  6.     acts_as_tree :order => "name"
  7.   end
  8.   Example:
  9.   root
  10.    _ child1
  11.         _ subchild1
  12.         _ subchild2
  13.   root      = Category.create("name" => "root")
  14.   child1    = root.children.create("name" => "child1")
  15.   subchild1 = child1.children.create("name" => "subchild1")
  16.   root.parent   # => nil
  17.   child1.parent # => root
  18.   root.children # => [child1]
  19.   root.children.first.children.first # => subchild1
  20. Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license