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
2
votes
2 answers
Acts as Tree with Multiple Models
I've got several models that I'd like to relate together hierarchically. For simplicity's sake, let's say I've got these three:
class Group < ActiveRecord::Base
acts_as_tree
has_many :users
end
class User < ActiveRecord::Base
acts_as_tree
…

Joseph Weissman
- 5,697
- 5
- 46
- 75
2
votes
3 answers
Rails: acts_as_tree and acts_as_sane_tree
This is the first time I'm modelling a hierarchy within the same model (product categories).
I found a great post on this topic. Since I use Rails 4 & Postgres, which according to the article supports recursive querying (this is the first time I…

migu
- 4,236
- 5
- 39
- 60
2
votes
1 answer
Displaing closure_tree in ActiveAdmin. How to create hierarhical view?
At minimal I want to achieve some indentation in index table. Like this:
+Parent
+--Child
+--Child of Child
+--Child
So I create the following:
ActiveAdmin.register Section do
config.filters = false
index do
column :name do |s|
"…

Astery
- 1,216
- 13
- 22
2
votes
2 answers
Does or can acts_as_tree be made to support eager loading?
Using acts_as_tree I would like to be able to preload an entire tree having its complete child hierarchy intact with one SQL call. To that end, I added a tree_id to the table and it runs through all descendants in that tree.
I had explored…

Mario
- 6,572
- 3
- 42
- 74
1
vote
1 answer
Caching dynamic Acts_as_tree category list
I have a Category model which uses acts_as_tree
class Category < ActiveRecord::Base
acts_as_tree :order=>"name"
end
When I display my category tree I use recursion, and an almost identical partial is generated each time (apart from some…

David
- 844
- 6
- 14
1
vote
1 answer
acts as tree in rails 3
I am facing problem with acts_as_tree_on_steroids with rails 3.
Is there any plugin which will help in rails 3 same as acts as tree
app/controllers/question_attributes_controller.rb:9:in `index'
Rendered…

shweta
- 11
- 2
1
vote
1 answer
How to search a tree with sunspot & solr
I have a model that looks something like this
class Post
acts_as_tree
end
What I want to do is conduct a search on the contents of an entire thread of posts, but only return the parent post in the results, and paginate these results.
I've read…

Adam Singer
- 2,377
- 3
- 18
- 18
1
vote
1 answer
enhancing a rails gem/plugin
I want to enhance the functionality of acts-as-taggable-on by adding parent_id and acts_as_tree to the tag model.
how do i edit the gem/plugin ?

Gady
- 1,514
- 2
- 16
- 32
1
vote
0 answers
Sort collection after associated resource's acts_as_tree/acts_as_list order
I have a SuccessCriterion model that implements both acts_as_tree and acts_as_list so it can be arranged as sorted tree hierarchy. Every success criterion can has many Boilerplate objects.
class SuccessCriterion < ActiveRecord::Base
has_many…

Joshua Muheim
- 12,617
- 9
- 76
- 152
1
vote
1 answer
acts_as_tree and active_model_serializer
Currently I'm building an API where I have a model functioning as a category. The category has possible subcategories and/or a single parent category created using the acts_as_tree gem. I wish to serialize the category model and it's relations to…

Daniël de Wit
- 2,206
- 1
- 16
- 13
1
vote
0 answers
How to use ruby acts_as_tree gem with Ember.js?
The gem in question is : https://github.com/rails/acts_as_tree
I used acts_as_tree as an approach to nesting and outputting comments on my app. The following code, in _comment.html.erb, works fine.
<%=…

Darshan
- 937
- 3
- 15
- 27
1
vote
1 answer
to_xml for fully-qualified trees using acts_as_tree
I have an ActiveRecord class that uses acts_as_tree. I'm trying to update the to_xml method so that if a child record's to_xml is called it will return it's xml nested in the parent/ancestor xml to give the fully-qualified path to that resource. …

Luke Imhoff
- 11
- 1
1
vote
0 answers
Acts_as_tree finding file location
I wonder how to use the available methods to find the location of the file in a folder.
For building breadcrumbs, this is easy. We can do
<% if @current_folder %>

curiousCoder
- 192
- 1
- 17
1
vote
1 answer
JQuery File Upload and Carrierwave to Detect Folders and Sub Folders
I have a fairly simple file upload system. Whenever multiple files are uploaded, it creates a new record in the database and stores the file name under the field file_leaf. Within the application, you can create subfolders and they are indicated by…

kobaltz
- 6,980
- 1
- 35
- 52
1
vote
1 answer
Is it possible to have file-system-like routes with acts_as_tree?
I have a Folder model which acts_as_tree.
Is it possible that the routes represent the folder structure?
Folders:
1: Folder A
2: Folder B
3: Folder C
4: Folder D
5: Folder…

Daniel Rikowski
- 71,375
- 57
- 251
- 329