similar to: acts_as_tree parent id problem

Displaying 20 results from an estimated 2000 matches similar to: "acts_as_tree parent id problem"

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
2005 Jul 25
2
acts_as_tree and traversing parent/child relationships
I am working on an Rails application that uses a pretty complex category structure through out the site. I have defined a table to house all the info and a FK to reference parents within the table CREATE TABLE categories ( id int(11) NOT NULL auto_increment, name varchar(50) NOT NULL, parent_id int(11) default NULL, constraint fk_category_id foreign key (category_id) references
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,
2005 Oct 19
3
Finding all parents of acts_as_tree relationship
I''m using acts_as_tree to maintain a hierarchy of categories (each top-level category can contain multiple categories and each sub-category can contain multiple sub-categories, etc.). I want to be able to find all parents of a particular category. I realize that I can use @category.parent or even @category.parent.parent to move up in the hierarchy, but I need this to happen dynamically
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.
2006 Jun 08
2
counter_cache is not looking for children_count with acts_as_tree
Hi there, the acts_as_tree API says that I can set a counter cache and that it will automatically increment the "children_count" column. I did that but when I create a new page it asks for a "pages_count" column instead. Here is the relevant part of page.rb model: class Page < ActiveRecord::Base acts_as_tree :order => :position, :counter_cache => true
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_<%=
2006 Feb 08
1
Many-To-Many w/acts_as_tree?
Guys, I''m having a problem getting acts_as_tree working. It seems from the Agile book (p. 255) that acts_as_tree only supports one-to-one record relations, whereas I need many-to-many support. In other words, looking at the picture at the top of page 256 where where only 1 id is linked to 1 parent_id, I need multiple id''s linked to multiple parent_id''s - for
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
2007 Apr 30
2
acts_as_tree
Hi folks, For my app, I needed to modify acts_as_tree (ActiveRecord::Acts::Tree) such that deleting a node would orphan sub-nodes, rather than deleting them. This is accomplished simply by allowing a :dependent option to the acts_as_tree method so that it can be set to :nullify. For my app, I simply did this by adding a file tree.rb to my lib directory and requiring it in the model. A number
2006 May 30
2
acts_as_tree, acts_as_list and is invincible (help!)
So I have the following model class Topic < ActiveRecord::Base belongs_to :topic has_many :topics, :order => :position acts_as_tree :order => :position acts_as_list :scope => :topic_id end that I use for a site''s navigation. Everything (list, create, edit, even the drag&drop sort) works fine, except the destroy function, which the vanilla version def destroy
2006 Jan 16
2
acts_as_tree with Modified Preorder Traversal?
Has anyone extended Rails''s acts_as_tree to use the Modified Preorder Traversal algorithm? This is a really clever trick for optimizing access to trees stored in databases, as described lucidly in this article: http://www.sitepoint.com/article/hierarchical-data-database/2 It adds two integer fields, a "left counter" and "right counter", to each row. By
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 Jun 19
3
Using set_primary_key breaks acts_as_tree with non-integer column
I just switched from using the standard "id" column into using my own primary key and generating my own unique id for each record. But, this breaks acts_as_tree. Because my new primary key is not an integer, it breaks the SQL query as follows: StatementInvalid in PagesController#create --------------------------------------------------------------------------------------
2006 Nov 04
1
acts_as_tree repeats
Hello Railslist, I want to draw a simple single-table Acts_as_tree model. I''ve read some articles about it and read the API docs, and now I''ve got this running: in controller I have: --- def index @pages = Page.find(:all) end --- in the model for Page I have ofcourse: --- acts_as_tree :order => "position" --- in the helper I have; --- def
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
2005 Dec 15
4
Acts_as_tree and routing
I''ve got an acts_as_tree structure which I want to be able to represent in the URL, with one field identified as the url component. In other words, if I''ve got this: def self.up create_table :nodes do |t| t.column :parent_id, :integer t.column :tag, :string end end and class Node < ActiveRecord::Base acts_as_tree end and what I want the urls to be is something
2006 Jun 13
3
acts_as_tree problem accessing parent object
i have a model called certification_types that i''ve declared as acts_as_tree. I have a model called certification that belongs_to :certification_type . class CertificationController < ApplicationController ..... def summary_list @certifications = Certification.find(:all, :order=>''date'') end end summary_list.rhtml <% for certification in
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/.