Skip to content

Instantly share code, notes, and snippets.

@blasterpal
Created November 16, 2011 19:05
Show Gist options
  • Save blasterpal/1371000 to your computer and use it in GitHub Desktop.
Save blasterpal/1371000 to your computer and use it in GitHub Desktop.
Recursion of children
module ContentAllChildrenMethods
def all_my_children
kids = []
children.each do |child|
kids << child
kids << child.all_my_children
end
kids.flatten
end
end
class Content
include ContentAllChildrenMethods
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment