开发者

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 methodfoo'? 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜