similar to: Need help setting up and iterating thru a tree

Displaying 20 results from an estimated 8000 matches similar to: "Need help setting up and iterating thru a tree"

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
2006 Jan 05
1
Fixture files for inserting tree like behavior doesn''t work
Hi folks around, hope you could help me with my problem. I have a porblem while testing my Acts_as_Tree behavior with fixtures. Because all data in the fixture file will be commited at the end the entries I want to map my tree like structure to will not be present at this point. Due to this I get a foreign key constraints fails from the database. Is there any way to solve this problem? Here
2006 Jul 12
1
odd habtm behavior? or is it me?
Hello List, I''m a bit spent on this problem, and my code might be whack. I seem to be encountering a problem where the primary key on a join table is not being resolved correctly. I will elaborate after some code bits. I am creating the join table using migrations, and relevant model code is this: class Post < ActiveRecord::Base has_and_belongs_to_many :records
2006 Feb 24
2
how to better generalize a tree?
first some background info: I have a blog application that has a comments table with the following columns: id parent_id post_id created_at body here''s my model: class Comment < ActiveRecord::Base belongs_to :post acts_as_tree :order => ''created_at'' def print_children (options={}) before = options[:before] ? options[:before]
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 Feb 27
1
How to build a recursive parenting structure?
I''m just getting used to using HABTM structures. Something I''m trying to do now is create a site that has "sections" each section then could have a sub "section". So I built a "sections" table and in the model I included the line "has_and_belongs_to_many :sections" I also made a table called "sections_sections" to build the
2007 Mar 13
0
ActiveRecord: strange tree behavior???
hi, can someone help me with understanding, why i can''t get my set_sub_tree method to run correctly and what to do to make it work? when i run the testcase below i get --- D:\ruby\test>ruby test/unit/demo_test.rb Loaded suite test/unit/demo_test Started F Finished in 0.625 seconds. 1) Failure: test_set_sub_tree(DemoTest) [test/unit/demo_test.rb:13]: fails@4. <200> expected
2006 Sep 09
1
Acts as tree and list?
Does anyone have any experience using acts as tree and acts as list together? My model looks like class ModelName < ActiveRecord::Base acts_as_tree :order => "position" acts_as_list :scope => :parent end the table has fields position, :integer parent_id, :integer This kinda of seems to work. Except if I do something like @modelinstance.children.first.move_lower
2005 Sep 23
6
problem with acts_as_tree
Hi, I''m using the latest gem version of rails under MacOS Tiger. I was trying to use acts_as_tree as described in the rails book. So I have something like: class Category < ActiveRecord::Base acts_as_tree :order => "title" end create table categories ( id int not null auto_increment, title
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
2006 Jul 17
1
acts_as_tree and :include
hello there, i have a model that uses acts_as_tree: >class GbEntry < ActiveRecord::Base > acts_as_tree :order => ''created_at DESC'' >end and i want it to paginate, including all children to avoid unnecessary db queries: > @gb_entry_pages, @gb_entries = > paginate :gb_entries, :per_page => 15, :order => ''created_at DESC'',
2006 Jun 20
2
Converting from acts_as_tree to acts_as_nested_set
I''m currently using acts_as_tree to display threaded Comments on my forums-like site. It''s waaay too slow to display a page with 1,000 comments, as it''s issuing a TON of selects. I''m pretty sure I want to convert to the nested set model, using acts_as_nested_set or acts_as_threaded. This should give me the performance I''m looking for. The problem,
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 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 Feb 02
3
acts_as_family_tree
For a project that I am working on I need to have a family tree. This means that instead of having one parent each item has at most two. As far as I know acts_as_tree only allows one parent_id. Any suggestions on how to make a "acts_as_family_tree" ? Thanks, Mark -- -------------------------------------------------------------------- I am Mark Daggett and I approve this message.
2006 Apr 30
4
acts_as_ordered_tree
I need an ordered (sortable tree) and I just was thinking if somehting like this is possible: class Item< ActiveRecord::Base acts_as_tree :order => "position" acts_as_list :scope => ''parent_id = #{self.id}'' end For my understanding mixing of two acts_as should be p?ssible, at least in this case, right? Unfortunatly the :scope is not working, I am not
2006 Jan 15
2
acts_as_tree & acts_as_list for a single model?
Hi, If I have a db table categories - id - name - parent_id - position is it alright to have the Category model act_as_tree and for each level act_as_list? class Category < ActiveRecord::Base acts_as_tree :order => :position acts_as_list :scope => :parent_id end Thanks, Peter
2006 Jul 20
3
acts_as_tree
Hello, I''m trying to create categories that have their own subcategories, and each subcategory may have its own subcategories, .. and so on. After some reading, I found out that the best way for creating such a thing is to use acts_as_tree, but I didn''t find any tutorial or article that explain this in a clear way. After a lot of work I was finally able to create categories and
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 my issue: if I
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