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!