Created
January 8, 2009 09:23
-
-
Save hosiawak/44656 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
# New utility method to return ancestors and siblings and children | |
def ancestors_siblings_children | |
query = "#{scope_condition} AND (#{self[left_col_name]} BETWEEN #{left_col_name} AND #{right_col_name}) OR #{parent_col_name} = #{self.id} OR id = #{self.id}" | |
unless self[parent_col_name].nil? | |
query << " OR #{parent_col_name} = #{self[parent_col_name]}" | |
end | |
base_set_class.find(:all, :conditions => query, :order => left_col_name ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment