简体   繁体   English

rails:“ pollresponse”是查询字符串中不允许使用的魔术关键字吗?

[英]rails: is “pollresponse” a magic keyword that is not allowed in query string?

Spent an hour debugging an "impossible" situation, where a query string pollresponse=true was simply not being recognized. 花了一个小时来调试“不可能”的情况,在该情况下根本无法识别查询字符串pollresponse = true。

Basically, params[:pollresponse] seems to always be nil, even when the params hash clearly shows { 'pollresponse' => 'true' } 基本上,params [:pollresponse]似乎总是为零,即使params哈希清楚显示了{'pollresponse'=>'true'}

On a hunch, replaced it with another name and it worked as expected. 直觉上,将其替换为另一个名称即可正常工作。

So I assume there is something "magic" though googling "rails pollresponse" didn't give me anything obvious. 因此,我认为尽管搜索“ rails pollresponse”并没有给我带来任何明显的印象,但还是有一些“魔术”。

a) Is it in fact reserved and therefore illegal as a query param? a)它实际上是保留的,因此作为查询参数是非法的吗?

b) is there a list of other such reserved words which, if used as a query string param, will be ignored? b)是否有其他此类保留字的列表,如果将其用作查询字符串参数,将被忽略?

a) no, there is no magic keyword pollresponse for rails. a)不,没有关于rails的魔术关键字pollresponse。

b) make sure b)确保

  1. none of the gems/plugins that you are using in your rails-app somehow messes with your params-hash. 您在rails-app中使用的gem / plugins都不会以某种方式与params-hash混淆。
  2. you don't use the keyword somewhere in your code 您不在代码中的任何地方使用关键字
  3. you don't have a model, resource, whatever named exaclty the same, cause this might cause some confusion in rails 您没有模型,资源,无论名字叫exaclty都是一样的,因为这可能会引起Rails的混乱

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

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