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 -- 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.
