Thursday, November 29, 2007

Non Intrusive Flex/Rails Remoting

Objective: create an open source remoting framework to communicate between Flex UI and Rails server without modifying any rails code.

Solution: Rails restful scaffold resource generation.

Flex has some great xml processing tools. Rails can easily generate xml out of the box. So, match up the 7 rails restful methods with a Flex/AS3 framework and life is easy...

This library includes connection configuration, index, show, create, update, destroy classes that operate against a remote Rails site. The rails code can be generated using resource scaffolding and remain unmodified.

Here is a live demo. It's a simple list/detail application that uses the remoting framework.

Download the swc here or the source code here. Or, you can check out the the latest by running:

svn co

Source code for the demo application is also available here.

Using the framework is quite easy. Simply create a controller and register the rails host and services in your main application. Then, create handlers for the discrete service methods including query (list), fetch (show), create, update and delete. Custom methods can be created by extending RailsService and implementing the send() method.

I'm currently updating the documentation with a step by step tutorial.

No comments: