I am trying to submit a create and update request to rails using flex with multiple models. For example, imagine that we have a blog post and multiple comments.
The user comes and update the post and some comments, when he clicks on submit I want to send all updates.
If I send something like:
var params:Object = new Object();
params["post[text]"] = myPostText;
params["post[userid]"] = myPostUserId;
Then I can send a array with the comments: var ar:Array = ["comment 1", "comment 2"]; params["post[comments]"] = ar;
This work without problems (avoiding the problem with multiple attributes having the same name).
But my problem is that for the comments I need to submit multiple attributes, lets suppose that for each comment I need to submit a rank, I tried to do (pseudo code):
var ar:Array = new Array();
for each comment c {
ar.push({"text":c.text, "rank":c.rank});
}
params["post[comments]"] = ar;
This does not work, because for each comment the hash parameters on rails side will contain the string "[object Object]".
Does anyone know a way to submit multiple models on flex to rails?