1

i am changing from WebORB to Warhammerkids Rails3-amf - great choice, even tehre are some open issues. One those issues is, how can I get records from an association to the array, which is sent back to the Flex-Application. In WebORB the method of the controller looks like:

 def getClients(clientFilter,myMandant)
     clients = Client.find(:all, :conditions => {:account_id => myMandant}, :include => [:addresses, :contacts, :proofs])
  end

in Rails3-amf I have a similar construction:

def getClients()
     @clients = Client.find(:all, :conditions => {:account_id => params[1]}, :include => [:addresses, :contacts, :proofs])
    respond_with(@clients) do |format|
       format.amf { render :amf => @clients}
  end

With this code I get back all correctly typed Client Objects as an Array, but without the records from the ":include" argument. How can I handle this ??

I also tried another way with:

....
respond_with(@clients) do |format|
       format.amf { render :amf => @clients.to_amf(:include => [:addresses, :contacts, :proofs])}
....

With this try I got an error message" undefined method to_amf for #.

Thanks for any help.

crikos
  • 41
  • 2

1 Answers1

1

I don't know about rail3-amf, but you might find it worthwhile having a look at restfulx - https://github.com/dima/restfulx/tree/rails3

It consists of a library for rails, and a library for flex. It supports data transfer through json, xml, or amf.

The actionscript api for working with models is very nice too:

var user:User = new User();
user.first_name = "Ed";
user.create();

It can also keep track of rails associations etc.:

trace(user.account.title);

See more usage here - https://github.com/dima/restfulx_framework/wiki/Working-with-RestfulX-Models

gunn
  • 8,999
  • 2
  • 24
  • 24