我正在从WebORB改成Warhammerkids Rails3-amf -这是个不错的选择,甚至还有一些悬而未决的问题。其中一个问题是,我如何从与数组的关联中获取记录,该数组被发送回Flex-Application。在WebORB中,控制器的方法如下所示:
def getClients(clientFilter,myMandant)
clients = Client.find(:all, :conditions => {:account_id => myMandant}, :include => [:addresses, :contacts, :proofs])
end在Rails3-amf中,我有一个类似的结构:
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使用这段代码,我将所有输入正确的客户端对象作为一个数组返回,但没有":include“参数中的记录。我该怎么处理??
我还尝试了另一种方法:
....
respond_with(@clients) do |format|
format.amf { render :amf => @clients.to_amf(:include => [:addresses, :contacts, :proofs])}
....通过这次尝试,我得到了一个错误消息“undefined method to_amf for #.
谢谢你的帮助。
发布于 2011-01-19 18:11:35
我不知道rail3-amf,但您可能会发现值得一看restfulx - https://github.com/dima/restfulx/tree/rails3
它由一个rails库和一个flex库组成。它支持通过json、xml或amf进行数据传输。
用于处理模型的actionscript api也非常好用:
var user:User = new User();
user.first_name = "Ed";
user.create();它还可以跟踪rails、关联等:
trace(user.account.title);在此处查看更多用法- https://github.com/dima/restfulx_framework/wiki/Working-with-RestfulX-Models
https://stackoverflow.com/questions/4728332
复制相似问题