# "undefined local variable or method" in view, for "if var"

**URL:** <https://www.ruby-forum.com/t/undefined-local-variable-or-method-in-view-for-if-var/153974>\
**Category:** Deployment\
**Created:** [November 24, 2008, 7:09am UTC](https://www.ruby-forum.com/t/undefined-local-variable-or-method-in-view-for-if-var/153974 "2008-11-24T07:09:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![squ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@squ](https://www.ruby-forum.com/u/squ)\
**Post date:** [November 24, 2008, 7:09am UTC](https://www.ruby-forum.com/t/undefined-local-variable-or-method-in-view-for-if-var/153974/1 "2008-11-24T07:09:13Z")

</div>

Hey, this feels like a dumb question, but I feel like this should be  
working.

I have a partial, and sometimes when I render it I’m passing in a  
variable via :locals called “invisible”, because sometimes I want it to  
start out as “display:none” then use js to make it appear. If I don’t  
pass it that variable, I want it to display normally.

So I have this line in my view:  
\<% if invisible %\>  
style=“display:none;”  
\<% end %\>

And I’m getting the “undefined local variable or method `invisible’”  
error. I would think that “invisible” would be nil, and evaluate to  
false, as it does in ruby code. Is that not the case with .html.erb  
files?

I tried this, and get the same result:

\<% if !invisible.nil? %\>  
style=“display:none;”  
\<% end %\>

Can anyone shine some light on this quirk? Is there a place that  
describes how erb works differently than ruby code?

Thanks in advance!
