Dec 01
Flex Ruby on Rails Sample App that uses Cairngorm 2.1 and WebORB
I recently updated the issue tracker sample application in the Flex RoR SDK so that it uses Cairngorm 2.1 and WebORB for Rails.
Besides showing how WebORB and Cairngorm can work together, this app demonstrates how to:
- use active record associations.
- return typed ValueObjects objects from Rails using the [RemoteClass] metadata tag.
- use dynamic finders inside Flex by directly mapping a Service to a ActiveRecord class.
- do simple effects in Flex.
- use states and transitions.
Let me know if you have any questions or comments, or if you find any bugs.
Credits:
The reflection on the login screen is by Ben Stucki.

December 5th, 2006 at 4:22 am
[...] I’ve set the issue tracker sample application that I recently added to Flex RoR SDK up on my site. [...]
December 6th, 2006 at 11:52 am
the zip file seems broken?
Did you manage to get specified objects on the AS side, or do you use vanilla vo’s (objects as associative array’s).
I ran into that the last time i played with webOrb and rails… (object graphs that need to be turned into actual objects on the flex side)….
curious to see how you set it up in this app…
December 6th, 2006 at 3:47 pm
Hi Ilya,
I just downloaded the the zip and opened it and everything worked. What was the problem that you encountered?
Yes, Rails is returning typed objects to Flex.
To get this to work you have to do two things
1. Use [RemoteClass] metadata tag to specify the alias for your class:
[RemoteClass(alias=\"com.rxr.issuetracker.vo.Issue\")]
public class IssueVO implements IValueObject
{
2. Go to config/weborb-config.xml in your Rails app and map the alias to a server-side class
December 9th, 2006 at 3:10 am
[...] You can get the source for this app, and learn a little about what is going inside, by going to this post: http://flexonrails.net/?p=31  [...]
December 10th, 2006 at 10:06 am
Hi Derek,
I was downloading the zip at a financial institution (client).
I guess it was their firewall…
Sorry for the confusion. I will renew my efforts to tear through the entire web-orb config.
I am seriously doubting between two approaches, and i wonder what you think about them:
1) Use the new REST approach with xml (or json)
advantage: no extra layers, simple setup.
-closer to the rails-way.
-the real cool thing is that unlike browsers, flex apps support the full gamma of HTTP headers (GET, POST, PUT, DELETE)
so your ruby controllers and models is where you model your app.
- So you get the testing structures automagically..
disadvantage: one has to jiggle cairngorm around a little. Inside the methods on your business delegate you have to specify the HTTP verb…
- possibly have much more services (and business delegators), the offset of this is that you have the REST style advantages (scalabillity through url partitioning and things like standard http caching configuration).
2) Use Web-orb:
advantage: close to vanilla cairngorm j2ee way of doing things.
one service supports many methods, clean architectural composition.
less boilerplate on flex side (turning xml states into value objects, or deserializing json objects.)
maybe i tweak your sample app to use the first approach and get a feel for the differences.
what do you think?
December 10th, 2006 at 8:07 pm
I read some stuff up on this topic on the google group. good overview of pro’s and con’s.
I guess there is no simple answer.
Thanks for providing this app Derek, it shows how to wire it up very nice.
I had trouble myself with the examples on midnight coders. Thanks.
Two questions: (if you prefer the google groups for dialogue let me know.)
U directly invoke methods on the User (Rails) object. I didn’t know that was possible. its an interesting aproach. Did you do it like this to round off the app quicker, or do you go this route on purpose?
You have some interesting boiler plate code (ValueObjectUtil.updateAttributes()).
Can you comment on why you use this method, instead of putting the objects that come back from the server on your model?
Curious ilya
December 10th, 2006 at 10:24 pm
Hi Ilya,
In addition to the points made on the google group, one thing to keep in mind is that you do not have to choose between using XML over HTTP (REST) or WebORB. You can use them together in the same app, if you need to.
I did go the route of directly invoking dynamic finders on the User object on purpose, but not necessarily because I think this is the best method. My goal was just to show that it is possible.
I use the ValueObject.updateAttributes() method because I think it is more efficient to update the properties on the selected object than it is to delete it and replace it with the object that I get back from the server. In other words, it is more efficient to make changes to the properties on an individual object than it is to make changes to a whole collection.
Derek
December 11th, 2006 at 1:35 am
[...] This is the first in a series of posts/tutorails that will cover certain features of the Issue Tracker sample app that I recently released. [...]