Hello,
I manage a database to map directories too ...
I use the plugin better_nested_set :
http://wiki.rubyonrails.org/rails/pages/BetterNestedSet
You can mange roots and children easily with this.
When you get, for example, a directory containing others directories
and files,
you can add the first directory as root and subdirectories and files
as children of root... with "child.move_to_child_of root"
When you want to get children for the root directory with your model :
"root.children" or "child.children" etc ...
And to get the parent directory : "chid.parent" or
"child.ancestors"
etc ...
You just have to parse the directory tree with Dir.entries or anything
else and add the results to the database using your model containing
acts_as_nested_set and saving each entries using move_to_child_of
method if it''s needed.
On 12 fév, 23:58, elioncho
<elion...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hello,
>
> Does anyone can give me some pointers on building a directory tree. I
> want to map a directory of folders and files into a database. I am not
> sure how to do this dynamically. I think acts_as_tree could help me do
> this. Any ideas?
>
> Thanks,
>
> Elias
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---