-
Notifications
You must be signed in to change notification settings - Fork 33
RestfulX Framework and Rails 2.1+
What you’ll need:
- Ruby on Rails 2.1.x to 2.3.x
- Flex SDK 3.0+
- MySQL 5.0+
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 rx:flex:build
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, create your project:
$>sudo gem install restfulx
$>rails -d mysql pomodo
$>cd pomodo
Edit config/environment.rb and add:
config.gem "restfulx"
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:
location: - name: string - notes: text - belongs_to: [user] - has_many: [tasks] project: - name: string - notes: text - start_date: date - end_date: date - completed: boolean - belongs_to: [user] - has_many: [tasks] task: - name: string - notes: text - start_time: datetime - end_time: datetime - completed: boolean - next_action: boolean - belongs_to: [project, location, user] note: - content: text - belongs_to: [user] 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
$>rake db:refresh
$>rake rx:flex:build
$>./script/server
Navigate to http://localhost:3000
You are done!
$>./script/generate rx_config -a
$>rake rx:air:build
$>rake rx:air:run
$>./script/generate rx_config
-
Getting Started with RestfulX and Ruby on Rails – This tutorial covers the same ground as the Getting Started with RestfulX and Rails in 5 minutes but goes over the steps in more detail as well as offers some background on scaffolding Flex + Rails applications using YAML
db/model.yml
file.
If you have an existing Rails application and you want to generate Flex artifacts only, use “rake db:schema:to_yaml”. This will generate a
model.yml
file for you based on your existing Railsschema.rb
file. (If you’re not sure yourschema.rb
is up to date, run “rake db:schema:dump” to refreshschema.rb
before you run db:schema:to_yaml.) Once you have amodel.yml
file simply run./script/generate rx_yaml_scaffold --flex-only
from your Rails app root.
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.
For more information on the RestfulX framework refer to RestfulX Framework Wiki
Want a more feature complete example? Check out Pomodo On Rails