views:

24

answers:

1

Hi,

I'm new to RubyAmf. I noticed that you can send an object with RubyAmf as follows:

format.amf { render :amf => @user}

Which works fine. But I wasn't sure what to do what when I have two ,or more, objects:

@projects = @user.projects
@tasks = @user.tasks

How can I can send @projects and @tasks without having to do multiple requests from flex.

Thanks,

Tam

+1  A: 

As per the RubyAMF code there is support array serialization. So the following code should work.

@projects = @user.projects
format.amf { render :amf => @projects}

If you want to send both projects and tasks together you can send them back in a hash.

format.amf { render :amf =>{:projects => @user.projects, :tasks => @user.tasks} }

Caveat: I haven't tested this code. I am inferring the functionality based on the gem code.

KandadaBoggu
Thanks @KandadaBoggu but can I send both @tasks and @projects together? I know I can send @projects array as you mentioned
Tam
I have updated my answer. Take a look.
KandadaBoggu