Why is this code throwing an ActionView::TemplateError
I have some straight forward code that looks like the following in one of my erb templates:
if (<%= is_defined? foo %>) /* some j开发者_如何学Pythonavascript to do stuff with foo */
Is there a reason that code is throwing an ActionView::TemplateError exception saying `undefined local variable or method
foo'? I thought is_defined?() should take care of that and not try to execute the code after utilizing foo if it isn't defined?
it's because you not define the foo method or variable in your view. Define it. You not generate some javascript. You generate some ruby code.
精彩评论