valley (2) [Avatar] Offline
Hi there,

i'm fighting with a huge problem by trying to send an array of objects from Flex to Rails in
an update POST request.
In the Rails app itself the same request part in the log file looks like this:

..."option_attributes"=>[{"title=>"Test", "id"=>"myid"}, {...}], ...

When i try to do the same update request from Flex it always results in a request like this:

..."option_attributes"=>"[object Object],[object Object], ... where object cannot be extracted.

The sending part in Flex looks like this:

var service:HTTPService = new HTTPService();
service.method = "POST";
service.url = "THE_URL";
object['_method'] = "PUT";
var token:AsyncToken = service.send(object);

where 'object' is of the type:

var object:Object = {};
object["poll[active]"] = poll_active.selected;
object["poll[id]"] = 5;

This part sent alone works perfectly in the Rails controller!

For the 'option_attributes' parameter i tried some sort of the following:

var options:Array = new Array();
options.push({"title": "Title", "id": "5"}); // do this for each option that exists
object["poll[option_attributes]"] = options;

Of course i also tried other possibilities, but i do not get to the solution described
at the top in the Rails version.

Is this not possible to pass an array of objects that arrive at Rails not only as [object Object]
elements, but as fully extracted objects, as described above ?
Or if it's possible please tell me what i am doing wrong here. I need a solution as it is
working in the Rails version, since the receiving update action should not be changed.

Thank you very much.
zhshxa (1) [Avatar] Offline
Re: Sending an array of objects to Rails
Hi Valley,

Have you gotten a solution for this?

I have the same requirement as yours.