Table: RailsNotes
User: dreamable
Created at: 2021-04-29 09:15:19 UTC
Updated at: 2021-04-29 09:15:49 UTC
Reference:(Table ID 3, Record ID 41)

标题 :
Get all children of children and so on
笔记 :

source

class Customer
  def descendants
    self.children | self.children.map(&:descendants).flatten
  end
end

| is array union.

[ "a", "b", "c" ] | [ "c", "d", "a" ]    #=> [ "a", "b", "c", "d" ]
[ "c", "d", "a" ] | [ "a", "b", "c" ]    #=> [ "c", "d", "a", "b" ]
Tag: