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.
2 responses to “Book Review: Flexible Rails: Flex 3 On Rails”
Hello, I found this blog article while looking for help with Microsoft Silverlight. I’ve recently switched browsers from Safari to Microsoft IE 6. After the change I seem to have a issue with loading websites that have Microsoft Silverlight. Every time I go on a site that requires Microsoft Silverlight, my computer freezes and I get a “npctrl.dll” error. I can’t seem to find out how to fix the problem. Any help getting Microsoft Silverlight to work is greatly appreciated! Thanks
You should post your question on the forum: