How do I get only the query string in a Rails route?

寵の児 提交于 2019-12-04 03:40:13

#query_parameters does exactly what you want:

request.query_parameters

It's also the most efficient solution since it doesn't construct a new hash, like the other ones do.

Stolen from the work of a colleague. I find this a slightly more robust solution, since it will work even if there are changes to the path parameters:

params.except(*request.path_parameters.keys)

I sort of solved this problem by doing this:

params.except("method","action","controller")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!