# Dojo Tree

**URL:** <https://www.ruby-forum.com/t/dojo-tree/125169>\
**Category:** Rails\
**Created:** [January 6, 2008, 3:56pm UTC](https://www.ruby-forum.com/t/dojo-tree/125169 "2008-01-06T15:56:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [January 6, 2008, 3:56pm UTC](https://www.ruby-forum.com/t/dojo-tree/125169/1 "2008-01-06T15:56:40Z")

</div>

Hello,  
I need to implement a drag and drop tree in rails. I saw the demo of the  
dojo tree and that is something that i wwould like to have. Can anyone  
please tell me how do i make that tree by getting the data from the  
DATABASE table and not from the file as given in the dojo example.  
Thank you.  
Regards,  
Anks

---

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [January 7, 2008, 10:18am UTC](https://www.ruby-forum.com/t/dojo-tree/125169/2 "2008-01-07T10:18:12Z")

</div>

That’s impossible to answer in any specific way without knowing what  
demo you’re talking about and knowing your data’s structure in the  
database, but I can guess at generalities:

- the demo is parsing the file and putting it in some kind of structure
- this structure is then fed through some code and handed to Dojo

So, for Rails, you have two problems:

- using Rails associations and finders to extract data from the  
database and manipulate it into a form that can be fed through some  
code and handed to Dojo.
- Running Dojo on Rails.

For the first problem you’ll have to look at the structure of the tree  
in the example and attempt to replicate that structure (or,  
alternatively, cut out the intermediate code and look for a way to  
hand the manipulated tree to Dojo directly).

For the second, there is at least one project (Dojo Toolbawks) to let  
you run Dojo with Rails.

-faisal

---

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [January 7, 2008, 6:53pm UTC](https://www.ruby-forum.com/t/dojo-tree/125169/3 "2008-01-07T18:53:06Z")

</div>

Have the model that describes the content you want to sort uses  
acts\_as\_tree, then use the example code from this page  
[http://dev.oriontransfer.co.nz/SortableTree/](http://dev.oriontransfer.co.nz/SortableTree/) to figure out how to use  
the  
Scriptaculous library. I don’t know if the most current Rails install  
version of dragdrop.js works - when I implemented this on my site a year  
or  
so ago, I needed to use the dragdrop.js from the example.

---

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [January 8, 2008, 1:13pm UTC](https://www.ruby-forum.com/t/dojo-tree/125169/4 "2008-01-08T13:13:44Z")

</div>

Cynthia K. wrote:

> Have the model that describes the content you want to sort uses  
> acts\_as\_tree, then use the example code from this page  
> [http://dev.oriontransfer.co.nz/SortableTree/](http://dev.oriontransfer.co.nz/SortableTree/) to figure out how to use  
> the  
> Scriptaculous library. I don’t know if the most current Rails install  
> version of dragdrop.js works - when I implemented this on my site a year  
> or  
> so ago, I needed to use the dragdrop.js from the example.

Hello,  
I saw the demo and this is what i would like to have. But  
unfortunately i could not find the source code. Do you have any idea  
where i can find the source code for the sortable tree.

---

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [May 21, 2008, 10:20am UTC](https://www.ruby-forum.com/t/dojo-tree/125169/5 "2008-05-21T10:20:04Z")

</div>

Hello  
Do you find the source code of example or maybe another simular  
solution?
