Ruby on rails Rails使用RESTful API交换数据
我试图理解如何使用POST/GET/PUT类型的请求从移动设备和API客户端交换数据 我有一个包含以下字段的表单Ruby on rails Rails使用RESTful API交换数据,ruby-on-rails,json,api,restful-architecture,Ruby On Rails,Json,Api,Restful Architecture,我试图理解如何使用POST/GET/PUT类型的请求从移动设备和API客户端交换数据 我有一个包含以下字段的表单 名字 年龄 性 位置 上面的表单在客户端验证后在移动设备上填写,然后我构建一个JSON,如下所示 { "name": "Harsha MV", "age": 28, "sex": "male", "location": "Bangalore, India" } 现在,我向URLhttp://example.com/users/create Post请求将包含一个
- 名字
- 年龄
- 性
- 位置
{
"name": "Harsha MV",
"age": 28,
"sex": "male",
"location": "Bangalore, India"
}
现在,我向URLhttp://example.com/users/create
Post请求将包含一个名为data
的持有者,该持有者将持有上述JSON
服务器端
我检查身份验证令牌,然后请求POST数据,然后查找数据
持有者,然后展开JSON,然后提供请求响应
#simple example
def testing
@data = JSON.parse(params[:data])
render plain: @data.inspect
# do all the manipulation to serve the request based on the DATA
end
我们是否需要将每个数据请求捆绑到POST请求中,并将其放入数据容器中。答案是肯定的。
更多有关:
还有一个类似的问题:
希望有帮助