Displaying 20 results from an estimated 100000 matches similar to: "acts_as_tree"
2007 Feb 14
3
eager loading parents and children (acts_as_tree)
I am struggling with how to do eager loading of an acts_as_tree model.
If the model Stuff acts_as_tree I know I can do this to get children as
well:
Stuff.find(:all, :include => :children)
But what if the model I am including is the one that acts_as_tree?
For example, say Picture belongs_to Category. Category acts_as_tree and
I want to get all pictures that are members of a category that
2008 Apr 12
1
acts_as_tree undefined method?
i have acts_as_tree installed as plugin under rails 2.0.2 and also its
defined in class TreeItems, but when i put this in my view
<ul class="tree_level1" id="cars">Furniture
<% TreeItem.root.category.children do |cat_children| %>
<li><a class="list_item" href="#"><%=h cat_children.name %></a></
li>
<%
2007 Jan 25
1
acts_as_tree with acts_as_list
Hello all,
I''m having trouble using acts_as_list with acts_as_tree
to order the "children". I''ve found a few old posts on the web
that seem to indicate that this once worked.
class Whatever < ActiveRecord::Base
acts_as_tree :order => :position
acts_as_list :scope => :parent_id
Although the ''position'' field is being populated,
it appears
2006 Dec 25
2
Active Record acts_as_tree and leaf depth
Using acts_as_tree, is it possible to get information of the depth a
tree leaf in relation to the root? Or is available to derive
information to save in the way "position" can be derived and saved for
acts_as_list.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To
2007 Oct 04
3
acts_as_tree - parent reference is outdated?
I''m experiencing some unexpected weirdness with acts_as_tree.
class Category < ActiveRecord::Base
acts_as_tree
has_many :variations
end
def variations
# some code that returns the parent category variations if we have
none
end
>> pc = Category.new
>> pc.variations << "foo"
>> pc.save
>> cc = Category.new
>> cc.parent = pc
>>
2006 Sep 13
1
Eager loading with acts_as_tree
So I have a model that acts_as_tree and I run a method on a collection
of all of these records. This method walks the tree and fetches the
parent/children, etc. This results in many, many duplicate SQL queries
to be executed. Is there a way to eagerly load all of these models?
Something along the lines of:
Model.find(:all, :include => [:children, :parent])
If I execute the above statement, I
2008 Jul 31
1
Getting a a list of acts_as_tree items with hierarchy
I''m using acts_as_tree to nest categories n-levels deep and am wondering
if anyone out there in Ruby-land knows the best, least expensive way to
start with top level categories and then loop recursively through each
category going as many levels deep as needed, and then moving to the
next top level category, etc.
Thanks,
Josh
--
Posted via http://www.ruby-forum.com/.
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
2007 Jun 27
3
acts_as_tree and before_save
We all know that acts_as_tree gives us ability to set up data in a
tree-like structure and use methods like ''parent'', ''children'' and so on.
Something I''m completely stuck on. Observe.
class Page < ActiveRecord::Base
acts_as_tree
def before_save
raise self.parent.to_yaml
end
end
Well, you''d think that it should show
2010 Mar 24
4
grouping and acts_as_tree
hi,
im using acts_as_tree and im not sure on how to group find-result.
x = find.almost_all
<p>
<% for y in @x.ancestors.reverse %>
<%= link_to h(y.title), page %> >
<% end %>
</p>
gives me a nice "breadcrum". but how is it possible to group the list lets
say by the 1level or second level?
thx
--
You received this message because you are
2009 Feb 19
3
Associated child records not created on creation of a parent.
I am trying to create a record with association. Within the create
method, I would also like to pre-populate dependent (has_many) records
from a template in the database.
The child records are <u>mysteriously rolled back </u> if I insert
them in a loop. If I try to insert a single child record, it works.I
have read the books and tried to google my way out of this but am at a
dead
2007 Sep 03
7
relationing has_many, belongs_to
Hello, i want to know if i am relationing fine, because i am having
problems,i have 2 models, one for members and other to relate some
members to this:
class Member < ActiveRecord::Base
has_many :matrix, :foreign_key=>:parent
end
class Matrix < ActiveRecord::Base
set_table_name :matrix
set_primary_key :userid
belongs_to :member, :foreign_key=>:userid
acts_as_tree
2012 Jun 08
7
filter children with acts_as_tree
Hello Experts,
I have a tree of categories in this category object there is a property
called type.
the root categories have no type but the children have. so how I can get
all the roots with filled in children that have category type = ''B'' for
instance.
I tried to run Category.roots then delete children With a category not
equal to ''B'' but this causes a major
2010 Feb 09
3
acts_as_tree question
Hi,
I''m trying to implement a very simple acts_as_tree search in my index
html.
I am able to show the parents, with no issue, but the children will
not show.
I have something like this for the parent, which displays fine:
<% for group in Group.roots %>
<td>
<tr>
<a href="#" onclick="Effect.BlindDown(''show_<%=
2007 Dec 09
3
Managing Hierarchical Data
Hello,
I am in the process of trying to date hierarchical data in a MySQL
database and convert it into a treeview view JS scripting. As a beginner
to ROR there are still many unknown things to me, and handling this sort
of data is one of them. My question is this: Is there any built in
functionality for handling hierarchical data (via a MySQL DB) in
Rails/Ruby? If there is can someone please
2010 Sep 11
10
Having difficulty with threaded comments, using acts_as_tree
I''ve been having problems making threaded comments for the last few
days. Mainly with creating children and displaying the children.
Currently, I have comments shown at the bottom of my articles show view.
The top level comments work, but I do not really know how to implement a
way for users to "reply" to the top level comments and take them to a
form (the comment
2009 Aug 19
10
acts_as_list / acts_as_tree / acts_as_nested_set - which one
I am creating forum application which needs usage of acts_as_list or
acts_as_tree or acts_as_nested_set.
I am unable to decide among these. please could some one recommend from
their experience?
--
Posted via http://www.ruby-forum.com/.
2006 Jun 17
2
URL based on acts_as_tree using routes
Hi There!
I''d like some feedback before I try to implement some funky rails
routes based on an acts_as_tree model.
I have a Page model that acts_as_tree. I''d like the URLs to look
something like this:
http://localhost/about-us/staff/jeff
or, another example...
http://localhost/what-we-do/products/our-great-cms/features/faqs/
So, as many sub-nodes the user creates,
2006 Apr 12
2
Why doesn''t acts_as_tree support :scope?
I want to implement a unique category tree per user in my system, and I
was hoping to use "acts_as_tree" on my category model. It seems as if
acts_as_tree makes the assumption that the entire table the model is off
of is one large tree. I actually want each user to have their own
category trees all stored in the category table so I need it to scope
off of the user_id.