Ruby on Rails 3:如何分离检索POST和GET PARAMS? [英] Ruby on Rails 3: How to retrieve POST and GET params separatly?

查看:69
本文介绍了Ruby on Rails 3:如何分离检索POST和GET PARAMS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我知道你可以使用 params 获取参数,但事实是它合并了所有参数,不管它们是通过 GET 还是 POST



如果您通过 GET 发送请求,没问题,参数只能在URL中被压缩。



但是,如果您发送 POST 请求,一个像 / blabla?foo = bar& foo2 = bar2 这样的URL是否有办法说明通过URL发送的变量和通过实际的 POST 方法?



希望我的问题清楚。谢谢!

解决方案

是的,在您的控制器中,您可以使用request.GET和POST参数与request.POST

So I know you can get parameters using params, but the thing is that it merges all parameters whether they were sent via GET or POST:

If you send a request via GET, no problem, the parameters can only be squeezed in the URL.

But if you send a POST request that has a URL like /blabla?foo=bar&foo2=bar2, is there a way to tell the difference between the variables sent via the URL and the variables sent through the actual POST method?

Hope my question's clear. Thanks!

解决方案

Yes, in your controller you can get the GET parameters using request.GET and the POST parameters with request.POST

这篇关于Ruby on Rails 3:如何分离检索POST和GET PARAMS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆