简体   繁体   English

在Rails中发布请求

[英]Post request in rails

I have android application which will send me some data in POST request to my rails app. 我有一个android应用程序,它将在POST请求中向我发送一些数据到我的rails应用程序。 How to handle that Post request in rails ie How do I write POST api for android app. 如何在Rails中处理该Post请求,即如何为Android应用编写POST API。 I have some knowledge about scaffolding in rails. 我对滑轨的脚手架有一些了解。

See " Rails' guide to routing ." 请参阅“ Rails的布线指南 ”。

The routing process is used to map a HTTP verb, like "POST", to a particular controller's action. 路由过程用于将HTTP动词(如“ POST”)映射到特定控制器的动作。 Typically, for Rails apps, the conventional method is MyController#create . 通常,对于Rails应用程序,常规方法是MyController#create In that controller, you will respond to the action with respond_to and a format for the response as mentioned in the Rails controller tutorial . 在该控制器中,您将使用response_to和Rails控制器教程中提到的响应格式来响应操作。

Your response will be based on the model implementing a serializer, or even better, delegating to a serializer for it, in order to create the API response for your Android app. 您的响应将基于实现序列化程序的模型,或者甚至更好的模型,该模型委派给序列化程序,以便为您的Android应用创建API响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM