I’ve written a little component for connecting flex with rails scaffold as close as possible.
Step 1: Create a scaffold for Card
Within your rails application run the script:
./script/generate scaffold card id:integer timeStamp:timestamp data:text
(data types with Ruby and mySQL)
Step 2: Change the Card controller
Edit the Card Controller found at: myApp/app/controllers/cards_controller.rb and remove all view elements. this will make the controller omit pure XML structures
should result with the controller looking like:
class CardsController < ApplicationController
# GET /cards
# GET /cards.xml
def index
@cards = Card.all
render :xml => @cards
end# GET /cards/1
# GET /cards/1.xml
def show
@card = Card.find(params[:id])
render :xml => @card
end# GET /cards/new
# GET /cards/new.xml
def new
@card = Card.new
render :xml => @card
end# GET /cards/1/edit
def edit
@card = Card.find(params[:id])
render :xml => @card
end# POST /cards
# POST /cards.xml
def create
@card = Card.new(params[:card])
if @card.save
render :xml => {:notice => ‘Card was successfully updated.’}
else
render :xml => {:notice => @card.errors}
endend
# PUT /cards/1
# PUT /cards/1.xml
def update
@card = Card.find(params[:id])if @card.update_attributes(params[:card])
render :xml => {:notice => ‘Card was successfully updated.’}
else
render :xml => {:notice => @card.errors}
endend
# DELETE /cards/1
# DELETE /cards/1.xml
def destroy
@card = Card.find(params[:id])
@card.destroy
render :xml => {:notice => ‘Card was successfully updated.’}end
end
Step 3: Client Side
To connect to the Rails server use an intermediate adapter called ActiveResourceClient.as
For testing, use the ServiceTester.mxml
original post: giladmanor.com
good luck