Rails3-amf - getting associated Records through amf

3 views
Skip to first unread message

crikos

unread,
Jan 18, 2011, 4:43:31 PM1/18/11
to rubyamf
everybody,
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
#<Array:0x88888888>.



Thanks for any help.

warhammerkid

unread,
Jan 19, 2011, 11:06:19 AM1/19/11
to rubyamf
Crikos,

I just added support for calling to_amf directly on the array, so the
code you tried before should work properly now. If you run into any
issues with it, submit a bug on github for it.

Stephen/warhammerkid

crikos

unread,
Jan 19, 2011, 12:49:10 PM1/19/11
to rubyamf
Hi Stephen,
you are THE BEST !!!! It is working fine now.
Thanks a lot for that change and of course for that very useful
plugin. Within the migration from WebORB I have to adapt about 30
controllers. With your approach dealing with Ruby and amf, it is a
job, which can be done within a few hours. This is very helpful.

Regards from Austria.
Chris
Reply all
Reply to author
Forward
0 new messages