ActsAsTree extends ActiveRecord to add simple support for organizing items into parent–children relationships. By default, ActsAsTree expects a foreign key column called parent_id.
Questions tagged [acts-as-tree]
52 questions
0
votes
1 answer
dependent destroy with acts_as_tree and acts_as_list
Currently I upgrade rails 2 application to rails 3.2.13 wich use acts_as_tree and acts_as_list. Before, the upgrade it works well. Since, I have a problem with acts_as_tree and acts_as_list with dependent destroy.
I have to models:
class User <…

CupraR_On_Rails
- 2,449
- 1
- 19
- 24
0
votes
1 answer
Are ActiveRecord associations valid before committing to database?
I have a model which uses acts-as-tree. For example:
class CartoonCharacter < ActiveRecord::Base
acts_as_tree
end
Acts as tree has these associations:
class ActsAsTree
belongs_to :parent
has_many :children
end
From script/console I am…

Mario
- 6,572
- 3
- 42
- 74
0
votes
1 answer
want to get a list of all the ids of something that acts_as_tree
I have a Category that can have Headers which are acts_as_tree. The structue could this be like:
class Category < ActiveRecord::Base
has_many :headers
end
class Header < ActiveRecord::Base
belongs_to :category
acts_as_tree :order =>…

timpone
- 19,235
- 36
- 121
- 211
0
votes
1 answer
Error when trying to display parent name using acts_as_tree
I am using the acts as tree gem to create a Category model:
1 class Category < ActiveRecord::Base
2 include ActsAsTree
3 attr_accessible :name
4
5 acts_as_tree order: "name"
6 end
In one of my views, I am trying to display the…

AlexBrand
- 11,971
- 20
- 87
- 132
0
votes
1 answer
Implement erb code in rails controller?
I wanted to render my model to json and include it's nodes when using acts_as_tree. I found this post and it helped alot: acts_as_tree and to_json or from_json
My only question is how to implement this in my controller. I want to return the json in…
0
votes
4 answers
Simple Acts_as_tree with nested_resources
Using Rails 3.1.1 and the gem acts_as_tree. I have googled the issue and checked similar questions here at SO (the answers are too old, or irrelevant).
I have a model called articles with a route that today looks like:
resources :articles, :path…

Christoffer
- 2,271
- 3
- 26
- 57
-1
votes
3 answers
My recursive function does not end. What am I doing wrong?
I have a model called folder that acts as a tree. Inside the model I have an instance method copy that copies folders from one place to another. When copying a folder, its sub-folders also have to be copied.
This is my code:
class Folder <…

Mischa
- 42,876
- 8
- 99
- 111