Created
June 16, 2009 18:23
-
-
Save avescodes/130809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.parent_select_options | |
options = [['-- No Parent --', nil]] | |
Tag.recurse_for_parent_select_options(Tag.roots,options) | |
return options | |
end | |
def self.recurse_for_parent_select_options(nodes,options) | |
nodes.each do |node| | |
prefix = node.depth > 0 ? ' -' * node.depth + ' ' : '' | |
options << [ prefix + node.title, node.id] | |
Tag.recurse_for_parent_select_options(node.children,options) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment