17 Hierarchical Data with RubyAMF

Goal

You want to get some structured, hierarchical data from Rails to Flex using RubyAMF.

Solution

Use a nested set Rails plug-in, such as awesome_nested_set (http://github.com/collectiveidea/awesome_nested_set), and RubyAMF’s method class mapping option to return an object graph to Flex with one call.

Nested Sets

Rails has a few options for storing hierarchical data, and one of them is called “Awesome Nested Set,” which is, you must admit, an awesome name. A Nested Set is a way to store data that maps into a hierarchical, tree-like structure in a database table, which does not natively support hierarchical relationships.

Basically, the idea is to store information about sets that contain ...

Get Flex on Rails: Building Rich Internet Applications with Adobe Flex 3 and Rails 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.