Book review by: Richard Mischook
A well written guide to using Ruby on Rails with Adobe Flex to create rich internet applications.
Recently I was working on one of my pet projects – an application for managing data mapping during the analysis phase of enterprise integration projects. The details of the application are not really important so I’ll spare you.
The first prototype was a web application built using Ruby on Rails. While this prototype was useful, it seemed pretty clear that a web-browser based user interface was just not going to cut it. In fact the more we played with it the more obvious it became that a desktop client was what was needed. The two predominant reasons for this were:
- The application needed to be able to handle loading and mapping potentially large tree- like data structures;
- The application needed to have some sort of off-line viewing capability so that an analyst could visit with a client and show them stuff
I still wanted to store the data on the network though so that other analysts, project managers and developers could access it. So a desktop application, storing and reading data from the network with the ability to cache that data for offline viewing was what was called for.
Rich Internet Application (RIA) Frameworks
There are a few competing solutions out there for doing RIA with the first obvious choice being one of the many AJAX frameworks. I have had some experience with AJAX both from the ground up as well as toying with a few of the frameworks, particularly the stuff that ships with Ruby on Rails. As a rule I really like the AJAX way for certain things but to the best of my knowledge (I may be wrong here) there is no AJAX framework that was going to give me access to the local file system for caching my data.
The only other option that I know of (there are probably more) was Microsoftʼs Silverlight; problem for me is itʼs pretty young and anyway Iʼm a Mac user for fracʼs sake! On the other hand I came across a copy of Flexible Rails and I thought that maybe I should give this a spin.
Well I knew jack about Flex or Flash but I have spent some time over the last couple of years playing with Rails. On the other hand I have done some Visual Basic and Java Swing coding over the years and a bunch of web stuff so Iʼm no stranger to GUI programming paradigms.
Flexible Rails was a great intro to Flex 3 and how to use it effectively with Ruby on Rails. The author builds his book on a REST-based interface between his Flex client and the Rails back end. If youʼre not familiar with the term REST, it refers to a set of principles for constructing web services, the details of which which I wonʼt go into here. The main point to note is what you end of with is a Flex client sending and receiving XML to and from the Rails back-end. The techniques used leverage Railsʼ built-in ability to render database objects as XML (and indeed accept XML for creating/updating those same database objects).
One flaw I found was that the author was willing to accept that he would be unwilling to POST XML to the Rails back end – if he remained true to the REST URL naming principles. Luckily Rails still provides support for non-REST-full URLs and using these does allow you to send XML for creating and updating ActiveRecord objects.
Putting aside this relatively minor issue, the author provides some great work arounds for some Rails limitations/features such as the default conversion of underscores to hyphens in XML rendered by Rails. Particularly cool is his integration of the Rails validation frameworks with those provided by Flex.
When it comes to using Flex I can only assume that the strategies provided by the author represent best practices in the Flex arena. As far as I could see good object oriented principles were on display as well as good separation of concerns in the design. Certainly as a Flex novice I found the examples to be very illuminating although I quickly graduated to using the Flex API documentation (which is very good) combined with the current mother of all reference libraries – Google.
A well written very readable book that not only serves as a good introduction to Flex 3, but more importantly provides a sound basis for using Flex 3 and Ruby on Rails together.
Tags: RubyThis post was written by: Stefan Mischook
This entry was posted on Thursday, June 5th, 2008 at 11:06 pm and is filed under Book Reviews, Programming, Ruby. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.