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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.