views:

38

answers:

1

I want a Flex UI to send a string of text to Rails which will process and return a string of text. Wash, rinse, repeat. That's all I want. All of the examples I am finding are much more complex and not very informative given my noobiness.

Thanks in advance,

NJ

A: 

In Flex, use an HTTPService object to send a POST request to the Rails app with the text to be processed.

In your mxml:

<mx:HTTPService id="textService" url="http://myrailsapp" resultFormat="text"
    result="onTextLoaded(event)" fault="onTextServiceError(event)"/>

In your as:

private function processText(textToProcess:String):void
{
    textService.send( { text: textToProcess } );
}

private function onTextLoaded(event:ResultEvent):void
{
    var text:String = event.result as String;
}

private function onTextServiceError(event:FaultEvent):void
{
    // handle error
}

Then just create a controller in your Rails app to process and return the text. There should be many good tutorials out there on how to handle a POST in Rails.

Judah Menter
Thanks. Actually, I am having a hard time finding a Rails example of handling a POST as you describe. Any ideas?
NJ