Questions tagged [acts-as-tree]

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.

52 questions
15
votes
4 answers

Reddit-style nested/threaded/indented comments for Rails?

I'm wondering if someone has already built a system for threaded comments (for lack of a better term) in Rails or if I need to build it myself. In case it's not clear, what I'm referring to is a comment system like Reddit's that automatically…
Willem Obst
8
votes
3 answers

Formtastic select with grouping

Now with Formtastic I have plain select: = f.input :category, :as => :select, :include_blank => false, :collection => subcategories Here I show only children categories. I use acts_as_tree plugin for parent-child relationship. I would like to show…
Voldy
  • 12,829
  • 8
  • 51
  • 67
5
votes
3 answers

Acts-as-tree in Rails3?

I need to use Acts As Tree in my Rails3 project (ruby 1.9.2). But, there are lot of forks on github, so I don't know which should I choose, and which is used by other developers? On Railsplugins.org there are…
swistak35
  • 51
  • 1
  • 3
5
votes
1 answer

Why do my root nodes end up with themselves as the parent_id with acts_as_tree?

I have an existing tree structure to which I'd like to add a new root and move the existing roots down one. I've written a rake task which works fine apart from one thing. The new root ends up with a parent_id which matches it's new id instead of…
Simmo
  • 1,717
  • 19
  • 37
5
votes
2 answers

acts_as_tree does not destroy the model's children

I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end And I have this test class TaskTest < Test::Unit::TestCase def setup @root = create_root end def…
gsmendoza
  • 385
  • 1
  • 5
  • 12
3
votes
2 answers

acts_as_tree and propagating a value through sub headers to items

I have a little bit of a complex model and want to get the full functionality capable with my limited understanding of rails. I have a section, a header (which uses acts_as_tree), and an item. I use json to bring sets of data in. This has worked…
timpone
  • 19,235
  • 36
  • 121
  • 211
3
votes
1 answer

acts_as_tree vs ancestry gem for tree menu

I want to implement a tree menu (simple example of tree menu) in a Rails app that I am working on. I am unsure of whether to use acts_as_tree or Ancestry. Its seems that it would be easier to implements a simple tree menu using acts_as_tree,…
Tom Kadwill
  • 1,448
  • 3
  • 15
  • 21
3
votes
2 answers

acts_as_tree and has_many :through not working well together

I have the following: class Menu < ActiveRecord::Base has_many :menu_headers # has_many :menu_headers, :conditions => {:parent_id => 0} - was trying # to set parent_id to 0 for top level has_many :menu_items, :through =>…
3
votes
1 answer

acts_as_tree and rails 3.2.3, not compatible?

I am using Rails 3.2.3 and acts_as_tree 1.1.0. I have been using acts_as_tree for a handful different projects with earlier versions of Rails 3 (such as 3.1.1.) with no problems but it won't work at all for this version. If it is because of 3.2.3 or…
Christoffer
  • 2,271
  • 3
  • 26
  • 57
2
votes
3 answers

Generate a file list based on an array

I tried a few things but this week i feel like my brain's having holidays and i need to complete this thing.. so i hope someone can help me. I need to create a filelist based on a hash which is saved into a database. The has looks like this:…
pdu
  • 10,295
  • 4
  • 58
  • 95
2
votes
0 answers

RoR & ACTS_AS_Tree & display show page from database vs. display content

All, Working on a RoR app for work. Finally got acts as tree working with a database connection (railscast.com episode 162). Trying to shift from displaying content in the database to redirecting to the contents of the page.content database entry…
2
votes
1 answer

Building nested routes for a resource that use acts_as_tree

do you know how to generate dynamically routes such as: ... (/:parent_id(/:parent_id(/:parent_id(/:parent_id))))/:id I ask this question because I have a Folder model which acts as tree (it have a parent_id field), and its to_param method return…
Zag zag..
  • 6,041
  • 6
  • 27
  • 36
2
votes
0 answers

User is not able to make root of tree in acts_as_tree in rails 5.0

I am using acts_as_tree for creating tree structure of folder(model) in my rails app.But after adding acts_as_tree and when i try to make a root folder a error comes that parent must exist, indicating parent_id can't be nil . folder.rb : class…
Ankush Malik
  • 150
  • 2
  • 11
2
votes
0 answers

closure_tree ancestors is giving ancestors in reverse order

I have a rails (4.2.3) app that uses closure_tree on the Post model class Post < ActiveRecord::Base has_closure_tree dependent: :destroy end The closure_tree gem documentation states that: tag.ancestors is a ordered scope of [ parent,…
Anand
  • 3,690
  • 4
  • 33
  • 64
2
votes
1 answer

How do I create a scope on an associated closure_tree model?

I have two types: blogs and posts. Post uses the closure_tree gem (an acts_as_tree variant) to allow posts nested under posts. Also, each blog has_many posts. class Post < ActiveRecord::Base acts_as_tree end Given a set of blogs (by the same…
Anand
  • 3,690
  • 4
  • 33
  • 64
1
2 3 4