Developing Standalone AIR Applications using RestfulX

dima edited this page Aug 14, 2010 · 7 revisions

RestfulX framework allows you to develop standalone AIR Applications that integrate with your local SQLite database using the same set of high-level REST concepts you use when talking to Remote RESTful services.

While it’s possible to write the entire Application by hand, you can use a few handy generators that come with restfulx gem to help you get up and running faster. Note, there’s no need to install/or run Rails, Merb, etc. Ruby is a great language to for code generation. We use it to create a basic Rakefile and add a few RubiGen based generators to help you along the way. It is possible to open/edit any of these projects in Flex Builder 3 if you want to. In fact, when you use rx-gen generator project files for Flex Builder 3 and TextMate are created by default.

What you’ll need:

  1. Flex SDK 3.0 +
  2. Ruby 1.8.6 (for code generation, not required to use/run the application)

Before you start you might want to add Flex SDK bin folder to your $PATH variable if you haven’t already. This will allow you to invoke commands such as mxmlc from the command line and run rake tasks such as air:run and rx:air:build.

  • On OS X it’s typically /Applications/Adobe Flex Builder 3/sdks/3.0.0/bin
  • On Win32 it’s C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\bin

First, let’s create a project:

$>sudo gem install restfulx
$>rx-gen -a pomodo
$>cd pomodo

Then run:

$>./script/generate rx_config

Then create a file called db/model.yml:

$>touch db/model.yml

Edit db/model.yml to contain the following:

 - name: string
 - notes: text
 - start_date: date
 - end_date: date
 - completed: boolean
 - belongs_to: [user]
 - has_many: [tasks]

 - name: string
 - notes: text
 - belongs_to: [user]
 - has_many: [tasks]

 - name: string
 - notes: text
 - start_time: datetime
 - end_time: datetime
 - completed: boolean
 - next_action: boolean
 - belongs_to: [project, location, user]

 - content: text
 - belongs_to: [user]

 - login: string
 - first_name: string
 - last_name: string
 - email: string
 - has_many: [tasks, projects, locations]
 - has_one: [note]

Now we can generate the app:

$>./script/generate rx_yaml_scaffold

You are done! Look ma, no servers!

To run the app simply type:

$>rake air:run

To see the list of all available tasks type:

$>rake -T

While code generation is a quick way to get started, it falls far short of exposing you to all the things you can do with the framework. Examine the code you just generated and refer to Working with RestfulX Models for more information on what you can accomplish.

If you only want to use RestfulX for the DB magic, one approach is to keep the generated code in one project and copy the classes over as you re-generate (merging data is another issue). When you copy the classes over you will also need to copy the ProjectName-config.xml, specifically the parts that involve keep-as3-metadata. If you don’t you will see something like:
Error: model: [class YourTable] with qualified name: namespace.models::YourTable doesn’t have a valid [Resource(name=‘*’)] annotation.

As yet another alternative to copying the ProjectName-config.xml, you could just add the magic mxmlc compiler option to preserve the RestfulX metadata:


If you have any questions get in touch at RestfulX Framework Google Group

For more information on the RestfulX framework refer to Home.

Want a more feature complete example? Check out Pomodo On Rails

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.