ruby-on-railsapache-flexrubyamf

How can I send multiple objects with RubyAmf


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


Solution

  • 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.