Rails 3:在 Rails 中使用 JSON 响应 REST 式操作的正确方法是什么?
我正在尝试使用对 RESTful 资源控制器的 JSON 响应为我的 Rails 应用程序创建一个 API。这对我来说是一种新的体验,所以我正在寻找一些指导和指示。首先:
- 在 Rails 应用程序中,使用 JSON 响应 REST-ful 控制器方法的“正确”方法是什么? (创建、更新、销毁)
- 是否有一种惯用的方式通过 JSON 响应来指示成功/失败?
其他信息:
- 我目前正在使用rails 3.0.beta2,
- 我想避免使用插件或gem来完成繁重的工作,我的目标是更好地了解如何制作rails 3 API。
- 指向我可以找到有关该主题的更多信息的地方的链接也将受到赞赏,在谷歌上进行一些快速搜索并没有给我带来多大好处。
I'm trying to make an API for my rails application using JSON responses to RESTful resource controllers. This is a new experience for me, so I'm looking for some guidance and pointers. To start things off:
- In a rails application, what is the "proper" way to respond with JSON to REST-ful controller methods? (create, update, destroy)
- Is there an idiomatic way to indicate success/failure through a JSON response?
Additional information:
- I'm currently working with rails 3.0.beta2
- I would like to avoid using a plugin or gem to do the grunt work, my goal is to gain a better understanding of how to make a rails 3 API.
- Links to places I could find more information on the topic would also be appreciated, some quick searching on google didn't do me much good.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)