在单个请求中获取不同的活动资源模型

发布于 2024-07-20 01:35:48 字数 208 浏览 2 评论 0原文

是否可以在单个请求中接收不同活动资源模型的对象? 例如,请求“GET /user/joe/articles/1.xml HTTP/1.1”从服务器返回来自用户(“joe”)的一个对象和来自服务器的文章(id“1”)的另一个对象。

我知道可以将数组内的这些对象发送到客户端,但 ARes 无法处理它们。 是否有办法将响应“分成”两部分并将结果发送到不同的活动资源模型进行处理?

Is it possible to receive objects of different Active Resource models in a single request? For example the request "GET /user/joe/articles/1.xml HTTP/1.1" returns an object from User ("joe") and another object from Article (id "1") from the server.

I know it is possible to send these objects inside an array to the client, but ARes can't process them. Is there anyway to "break" the response in two and send the results to different Active Resource models for processing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天白云 2024-07-27 01:35:48

我认为您想要做的是将用户 xml 包含在返回的文章 xml 中。

如果您使用 ActiveRecord 制作 xml,则可以使用 to xml 调用以使用户包含在文章响应中。 输出类似于

<article>
  ...
  <user>
    ...
  </user>
</article>

您然后应该能够在返回的文章对象上调用“.user”以获取用户属性。

I think what you want to do is include the user xml inside the article xml that is returned.

If you are using ActiveRecord to make the xml the you can use the :include parameter of the to xml call to get the user included in the article response. The output is something like

<article>
  ...
  <user>
    ...
  </user>
</article>

You should then be able to call '.user' on the returned article object to get at the user properties.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文