查询字符串未在rails中完全读取

时间:2013-03-25 11:41:22

标签: ruby-on-rails ruby ruby-on-rails-3 curl libcurl

我在基于rails的api上有ruby,它接受get请求。 例如:

http://localhost:3000/api/search?query=whatis&access_token=324nbkjh3g32423

当我从mac终端卷曲时,如

curl http://localhost:3000/api/search?query=whatis&access_token=324nbkjh3g32423

我使用“request.fullpath”检查了服务器,它只返回“/api/search?query=whatis”,第二个参数丢失。

然而,如果我卷曲像

curl --data="query=whatis&access_token=324nbkjh3g32423" http://localhost:3000/api/search

它正在采取所有参数。

我知道编码存在问题,但我知道这两个请求有什么区别。

提前致谢

1 个答案:

答案 0 :(得分:1)

问题可能是bash shell将&视为命令的结尾。

尝试像这样引用整个查询字符串 -

curl "http://localhost:3000/api/search?query=whatis&access_token=324nbkjh3g32423"