Note: This article was created based on the Flex 3 beta releases. Minor changes in the description and code may be necessary before it can be applied to Flex 3.
Rails is a fantastic tool for web application development, but its Ajax-driven interfaces stop short of the richness you gain with a tool like Adobe Flex. Simply put, Flex is the most productive way to build the UI of rich Internet applications (RIAs), and Rails is the most productive way to rapidly build a database-backed CRUD application. Together, they're an amazing combination.
Peter Armstrong's recent book "Flexible Rails: Flex 3 on Rails 2" is a book about how to use Ruby on Rails and Adobe Flex to build next generation RIAs. The book takes you to the leading edge of RIA development, presenting examples in Flex 3 and Rails 2.
The excerpted chapter, "Chapter 11: Refactoring to RubyAMF", is about refactoring the example developed over the course of the book to using RubyAMF. In this chapter, you will start by installing RubyAMF and doing a quick "hello world" test. You will then refactor the tasks, projects, locations, and note used in the application to be sent between Flex and Rails via RemoteObject and RubyAMF to Rails, instead of using HTTPService and XML.
Flexible Rails is not an exhaustive Ruby on Rails tutorial, nor a Flex reference manual. Instead, it's an extensive tutorial, developed iteratively, how to build an RIA using Flex and Rails together. You learn both the specific techniques you need to use Flex and Rails together as well as the development practices that make the combination especially powerful.
Flexible Rails is for both Rails developers who are interested in Flex, and Flex developers who are interested in Rails. For a Rails developer, Flex allows for more dynamic and engaging user interfaces than are possible with Ajax. For a Flex developer, Rails provides a way to rapidly build the ORM and services layer of the application.
For more information about the book, visit the Flexible Rails site.
Some familiarity with Flex and Ruby on Rails.
In order to make the most of this article, you need the following software and files:
Peter Armstrong has been developing rich client applications for over seven years. He has worked with Flex full-time since July 2004 (since Flex 1.0). He was a key part of the Silicon Valley startup team whose Flex application won the 2006 Adobe MAX Award for RIA/Web Development. Before switching to Flex, Peter was a Java Swing developer for over four years for another Silicon Valley startup. On the Rails side, Peter has been tracking Ruby on Rails since mid-2005 (since before Rails 1.0) and is the organizer of The Vancouver Ruby/Rails Meetup Group. Peter is also a frequent speaker on using Flex and Rails together, including presentations at The Vancouver Flash/Flex Meetup, a standing-room-only RailsConf 2007 BOF presentation, The Vancouver RIA Developer Camp, and Rails to Italy in Pisa. Peter lives in the Vancouver, BC area and works as an independent consultant doing Flex, AIR and Rails development, training and workshops through his company Ruboss Technology Corporation.