简体   繁体   中英

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. Can a link to an image cause this?

I found this code as the only thing referencing anything regarding /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:

if(icon !== 'undefined'){

That test is looking for the string 'undefined' , not the value undefined . Perhaps you mean to check 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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