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

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -