It’s just data

Acts As Tree

Combining the Rails Confidence Builder and Atom’s processing model for content, and I’m nearly ready to consume some real data.  Trouble is, each feed contains both entries and comments.

The solution is acts_as_tree.  Adding the following to the DDL:

parent_id int,

And the following to class Entry:

acts_as_tree :order=>"updated"

And modifying the creation of new entries to look like this:

post = parent ? parent.children.create :

And I’m done.  Entries can have comments, and (for future growth) comments can be nested.  Class methods root and roots are defined, as well as instance methods for creating, querying, updating, and removing both parents and children.