gpt4 book ai didi

javascript - 如何找到导致 ActionController::RoutingError No Route matches 错误的原因?

转载 作者:行者123 更新时间:2023-12-01 01:49:19 25 4
gpt4 key购买 nike

我收到此错误。

ActionController::RoutingError (No route matches [GET] "/pins/undefined"): 

我已经搜索了导致此问题的代码,但看不到任何试图将用户引导至特定 URL myurl.com/pins/somethingdefinition 的内容。图像链接会导致这种情况吗?

我发现这段代码是唯一引用有关 /pins/ 的内容

 function constructMarker(icon){
if(icon !== 'undefined'){
return new goog.MarkerImage("/pins/" + icon,
new goog.Size(22, 38),
new goog.Point(0, 0),
new goog.Point(11, 18)
);
} else {
return new goog.MarkerImage("/pins/curve.png",
new goog.Size(22, 38),
new goog.Point(0, 0),
new goog.Point(11, 18)
);
}
}

还有这个

DOT = new goog.MarkerImage("/pins/GreenDot.png",
new goog.Size(20, 20),
new goog.Point(0, 0),
new goog.Point(10, 10));

for(var i=0; i<things.length; i++){
t = new goog.MarkerImage("/pins/" + things[i].icon,
new goog.Size(24, 50),
new goog.Point(0, 0),
new goog.Point(12, 25)
);

最佳答案

问题出在你的 JavaScript 中:

if(icon !== 'undefined'){

该测试正在寻找字符串 'undefined' ,而不是值 undefined 。也许您想检查typeof icon !== 'undefined' 。您可能可以使用更简单的 if(icon)检查一下,因为您不太可能关心零,false 、空字符串和其他与 undefined 不同的错误值.

关于javascript - 如何找到导致 ActionController::RoutingError No Route matches 错误的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51682528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com