debugging - In Ruby, why aren't variable names in the stack trace? -
debugging - In Ruby, why aren't variable names in the stack trace? -
in rails app associations (such post belongs_to user
), mutual exception this:
nomethoderror: undefined method `user' nil:nilclass
ubiquitously, causes beginners believe user
nil. why don't have more intuitive errors, such following?
nomethoderror: `@post' nil:nilclass , doesn't have method `user'
edit: why beingness downvoted? question legitimate. i'd know if there technical reason preventing this.
first of all, disagree original assertion. message says user undefined method, not variable or value. i'm not sure how think user variable based on message.
however reply question time "user" method called, target object has been loaded whatever variable referenced it. phone call logic invoking "user" doesn't know object came from. have been local variable, instance variable, constant...there's no way tell. also, rails "whiny nil" logic happens in method_missing implementation, far, far away original access of object; context of original variable lookup not in scope anymore.
ruby debugging exception stack-trace
Comments
Post a Comment