I manage a database to map directories too …
I use the plugin better_nested_set :
You can mange roots and children easily with this.
When you get, for example, a directory containing others directories
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”
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.