After creating has many relationships we can easily get the child and grandchildren list by recursively collecting children of parent’s children.
example below:
class Parent < ActiveRecord::Base
def children_list
children.map do |child|
[child] + child. children_list
end.flatten
end
end