El 02/08/12 13:39, Matt Jones escribió:
On Aug 2, 2012, at 2:24 PM, Quiliro Ordóñez wrote:
I have simplified the needs to something like this:
File table:
name:string
URL:string
user_id:integer
Tree table:
parent_file_id
child_file_id
So each file has many files! How can I construct this application.
Depends on what you're looking to do with the tree - for instance, for a simple
app you may be able to get away with just adding a parent_id column to File and
traversing the tree that way. (the classic acts_as_tree plugin did this)
If you regularly need to grab a node and *all* of its descendants, that method
will get gross in a hurry since it either requires a query per level of the
tree or crazy recursive SQL. For that sort of app, something like
awesome_nested_set may be better.
I'm not sure what the intention of your join table is - a single node has
exactly one parent in most tree structures.
BTW, you'll need to pick something other than 'File' - it's a Ruby stdlib class
and will make ActiveRecord blow up in exciting ways. :)
--Matt Jones
Thank you very much Matt.
The idea is to make an application that holds files and links them to
several other files. Those other files can be linked to other files in
that same database. Only one level is needed. What do you suggest in
this case?
I will investigate
awesome_nested_set
and
acts_as_tree
in the mean time.
--
Saludos libres,
Quiliro Ordóñez
Presidente
Asociación de Software Libre del Ecuador - ASLE
Av de la Prensa N58-219 y Cristóbal Vaca de Castro
Quito, Ecuador
(593)2-253 5534
(593)2-340 1517
(593)8-454 8078
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.