# How do you CRUD Acts\_As\_Tree data?

**URL:** <https://www.ruby-forum.com/t/how-do-you-crud-acts-as-tree-data/121580>\
**Category:** Rails\
**Created:** [November 29, 2007, 2:01am UTC](https://www.ruby-forum.com/t/how-do-you-crud-acts-as-tree-data/121580 "2007-11-29T02:01:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3e96dc/32.png) [@mjand](https://www.ruby-forum.com/u/mjand)\
**Post date:** [November 29, 2007, 2:01am UTC](https://www.ruby-forum.com/t/how-do-you-crud-acts-as-tree-data/121580/1 "2007-11-29T02:01:00Z")

</div>

I’m trying to create a simple category structure using acts\_as\_tree.  
I’ve been able to create the model, view, controller etc. but how do  
you create the edit page so you can identify the parent? I mean,  
what’s the best process of adding/editing records and associating them  
to another category in the tree? Do I have to pass in a parent\_id  
before I add a new record, or can I use some kind of select box, etc?  
Any best practices here?

---

<div class="post-metadata">

**Author:** ![mjand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3e96dc/32.png) [@mjand](https://www.ruby-forum.com/u/mjand)\
**Post date:** [November 29, 2007, 5:35pm UTC](https://www.ruby-forum.com/t/how-do-you-crud-acts-as-tree-data/121580/2 "2007-11-29T17:35:10Z")

</div>

On Nov 28, 2007 7:00 PM, Michael A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m trying to create a simple category structure using acts\_as\_tree.  
> I’ve been able to create the model, view, controller etc. but how do  
> you create the edit page so you can identify the parent? I mean,  
> what’s the best process of adding/editing records and associating them  
> to another category in the tree? Do I have to pass in a parent\_id  
> before I add a new record, or can I use some kind of select box, etc?  
> Any best practices here?

I’d just add a parent category drop down menu to my category add form.  
If you pick nothing you make the new category a top level category.  
Otherwise it’s a child of the selected parent.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)
