Displaying 7 results from an estimated 7 matches for "all_children".
2005 Oct 12
2
Help with act_as_nested_set
...ay_children(list)
puts list.map {|child| child.name + "[#{child.id}]" }.join(", ")
end
display_children(root.direct_children) # Fiction, Non Fiction
display_children(non_fiction.direct_children) #Science[129], History[130],
Computers[131]
display_children(non_fiction.all_children) #Romance[135], Science
Fiction[136]
display_children(non_fiction.full_set) #Romance[135], Science
Fiction[136], Non Fiction[128], Science[129]
These
display_children(non_fiction.all_children) #Romance[135], Science
Fiction[136]
display_children(non_fiction.full_set)...
2006 Jul 18
1
Bad values for acts_as_nested_set?
I moved from acts_as_tree to acts_as_nested_set because I need the
all_children method.
I''ve seen an alternative way to add this method to acts_as_tree here:
http://www.chuckvose.com/articles/2006/05/24/recursive-children
But I''d prefer to use the more efficient way of acts_as_nested_set (and
not to have to revert to my old code).
Anyway, here''s m...
2007 Apr 29
1
better nested set and :through
...has_many :groups, :through => :memberships
end
Now then, what i''d like to know is how do i go about finding all the
Users contained within a nested set?
for example:
admins = Group.find_by_name "admins"
admins.users # gives all users in the admins group.
and
admins.all_children # gives me all the groups
I thought the following methods sounded promising, but i get
NoMethodError''s from them:
admins.children.find_all_in_users
admins.children.find_in_users
Perhaps i''m going about this the wrong way or i''m missing a more obvious
solution. Can an...
2006 Aug 06
2
better_nested_set plugin
...array of all parents and self
* siblings - array of all siblings, that are the items sharing the
same parent and level
* self_and_siblings - array of itself and all siblings
* children_count - count of all immediate children
* children - array of all immediate childrens
* all_children - array of all children and nested children
* full_set - array of itself and all children and nested children
Subversion repository:
http://opensource.symetrie.com/svn/better_nested_set/trunk
README and code browsing
http://opensource.symetrie.com/trac/better_nested_set
It''s...
2007 May 02
3
acts_as_tree related question
hi,
I''ve a normal Category model implemented with acts_as_tree (name,
parent_id) that has_many :products (name, category_id).
What I''m asking for is a method to fetch every product that belongs
fall into a particular category and its children, eg: if I''m asking
for a root node (/category/show/1) I need to display every product
that have category_id = 1 AND every product
2009 Feb 17
8
Converting Acts_As_Tree to Acts_As_Nested_Set
Hello,
I have a tree structure that needs to be converted into a nested set.
A great deal of work has already been done on the tree items, so
maintaining the integrity of the id''s is mandatory. However I need
the ability to access entire branches of the tree, which is what
Nested set does. Does anyone have any suggestions on how to
efficiently transfer the tree to the nested set and
2006 May 31
1
Help enhancing acts_as_nested_set
...def full_set
self.class.find(:all, :conditions => "(#{left_col_name} BETWEEN
#{self[left_col_name]} and #{self[right_col_name]})", :order =>
"#{left_col_name} ASC" )
end
# Returns a set of all of its children and nested children
def all_children
self.class.find(:all, :conditions => "(#{left_col_name} >
#{self[left_col_name]}) and (#{right_col_name} < #{self[right_col_name]})",
:order => "#{left_col_name} ASC" )
end
# Returns a set of only this entry''s immediate children...