
WebORB for Ruby on Rails provides an implementation of the RPC functionality available in Adobe's Flex Data Services. Using WebORB Ruby developers can integrate Flex client applications with services deployed in Rails applications.
This guide reviews the process of creating a Flex RPC client using Flex Builder 2.0 and connecting it with a Ruby on Rails application. At the end of the walkthrough you will have a Flex application communicating with a Ruby object exposed through WebORB on Rails.
Make sure the following software is installed before downloading WebORB for Rails:
Ruby on Rails v.1.1.4 or newer
We recommend the following guide for installing Ruby and Ruby on Rails: http://wiki.rubyonrails.org/rails/pages/GettingStartedWithRails
Once Ruby and Rails is installed, create a new Rails application:

Change the current directory to the directory for the new rails application and run the following command to download and install WebORB into the current Rails application:

Now WebORB for Rails is installed and ready to process Flex and Flash Remoting invocation requests. Start a web server for your Rails application using the "ruby script/server" command:

You can verify the installation by running a remoting test suite application bundled with the WebORB distribution. Open http://localhost:3000/examples/main.html in a browser. When the application is loaded, you can run various invocation tests. Each tests invokes methods on Ruby classes distributed with WebORB and now deployed in your Rails application.
Run Flex Builder 3 and select File -> New -> Flex Project. The dialog window shown below will appear. Enter "SampleFlexToRubyProject" as the project name. Make sure to select "Other" as the Application server type. Make the selections as shown in the image below and click "Next >".

In the next step you need to point Flex Builder to a directory where it will compile the Flex application to. This tutorial uses the "sampleapp" in the "public" folder in the new rails application. You can enter any other directory under the "public" folder even if it does not exist at the time when the Flex Builder project is being created.
Use the "Browse..." button to select a directory or enter it manually as shown below and click "Next >":

Enter the URL corresponding to the output folder configured in the previous step. This guide used the following physical path:
The corresponding URL is:
This URL is important for running and debugging the compiled Flex application directly from Flex Builder. Enter the output URL in the field at the bottom of the screen as shown below and click "Finish".

At this point Flex Builder has created the project and added a default, blank Application file. However, there is an additional configuration step and by far it is the most important one.
Right click the project node in the "Flex Navigator" panel and select Properties. Select "Flex Compiler" and enter the following parameter into the "Additional compiler arguments" as shown in the image below:
-services c:\[RAILS-APP-PATH]\config\WEB-INF\flex\services-config.xml
Since the application from this guide is installed in c:\ruby\myrailsapp, the full path is:
-services c:\ruby\myrailsapp\config\WEB-INF\flex\services-config.xml
Enter the parameter as shown in the image below and click OK.

WebORB for Rails product distribution contains a finished Flex application demonstrating Flex to WebORB connectivity and a remoting invocation. Copy and paste the contents of the example.mxml file located at
\public\examples\
into the mxml file created in Flex Builder. The code in the application connects to a Ruby object and retrieves some basic information about the computer where the object is running.
Flex applications require a declaration of the exposed classes as "destinations". Destinations must be configured in remoting-config.xml located in the \config\WEB-INF\flex folder. The application in this example uses the "InfoService" destination defined as:
Flex Builder loads the configuration file during the compile time. If you change the configuration file after the Flex application is compiled, make sure to use the Project > Clean feature of Flex Builder, since the configuration file may be cached.
When you run the application in Flex Builder, it opens a browser and loads the application from:
http://localhost:3000/examples/SampleFlexToRubyProject.html
The application connects to the backend
service upon the startup or when user clicks the "Send
Request" button:
Flex application declares a remote object using the RemoteObject API:
Notice the destination name matches the destination entered in remoting-config.xml. When a user clicks the 'Get Computer Info' button, the following function executes a remote method invocation:
When an invocation response is available, Flex invokes a response handler specified in the
The source code for the server-side object is below: