简体   繁体   English

如何找到导致ActionController :: RoutingError的原因,没有路由匹配错误?

[英]How can I find what is causing the ActionController::RoutingError No route matches error?

I am getting this error. 我收到此错误。

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

I have searched for the code that would be causing this, but cannot see anything that is trying to direct a user to a specific URL myurl.com/pins/somethingdefined. 我已经搜索了可能导致此问题的代码,但是看不到任何试图将用户定向到特定URL myurl.com/pins/somethingdefined的内容。 Can a link to an image cause this? 链接到图像会导致这种情况吗?

I found this code as the only thing referencing anything regarding /pins/ 我发现此代码是唯一引用关于/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)
    );
  }
}

AND THIS 和这个

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)
    );

The problem is in your JavaScript: 问题出在您的JavaScript中:

if(icon !== 'undefined'){

That test is looking for the string 'undefined' , not the value undefined . 该测试正在寻找字符串 'undefined' ,而不是值undefined Perhaps you mean to check typeof icon !== 'undefined' . 也许您的意思是检查typeof icon !== 'undefined' You could probably get away with a simpler if(icon) check since you're not likely to care about zeros, false , empty strings, and other falsey values differently than undefined . 您可能可以通过更简单的if(icon)检查来解决问题,因为您不太可能关心与undefined不同的零, false ,空字符串和其他falsey值。

暂无
暂无

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

相关问题 ActionController :: RoutingError(没有路由与[GET]匹配” / assets / javascripts - ActionController::RoutingError (No route matches [GET] "/assets/javascripts 为什么我得到这个 ActionController::RoutingError (没有路由匹配 [GET] “/users/assets/application.js”) - Why I am getting this ActionController::RoutingError (No route matches [GET] “/users/assets/application.js”) Rails CORS:ActionController::RoutingError(没有路由匹配 [OPTIONS] &quot;/batches&quot;): - Rails CORS: ActionController::RoutingError (No route matches [OPTIONS] "/batches"): ActionController :: RoutingError(没有路由与[GET]“ / javascripts / application.js”匹配) - ActionController::RoutingError (No route matches [GET] “/javascripts/application.js”) 如何从另一个Rails项目中调用JavaScript文件? ActionController :: RoutingError(没有路由与[GET]“ / assets / trackmetrics.js”匹配) - How do call a javascript file from another Rails project? ActionController::RoutingError (No route matches [GET] “/assets/trackmetrics.js”) RoutingError(没有匹配的路由[OPTIONS] - RoutingError (No route matches [OPTIONS] ActionController :: RoutingError(没有路由与[GET] controller_name / fusioncharts.widgets.js匹配 - ActionController::RoutingError (No route matches [GET] controller_name/fusioncharts.widgets.js Ruby on Rails:PDF.JS ActionController :: RoutingError(没有路由与[GET]“ / pdf js / web / viewer.html”匹配): - Ruby on Rails: PDF.JS ActionController::RoutingError (No route matches [GET] “/pdf js/web/viewer.html”): ActionController :: RoutingError(没有路由匹配[GET]“/members/js/bootstrap.min.js&quot;):(Missing资产文件) - ActionController::RoutingError (No route matches [GET] “/members/js/bootstrap.min.js”):(Missing Asset files) ActionController::RoutingError (没有路由匹配 [GET] “/vendor/assets/stylesheets/bootstrap.min.css”) - ActionController::RoutingError (No route matches [GET] “/vendor/assets/stylesheets/bootstrap.min.css”)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM