It appears that when I call a helper method from one of my views, I am unable to set any new local variables. Name doesn’t matter – everything I set is nil.
From most views, everything is fine:
editable = true
html << 'Editable: ' + editable.to_s
Outputs Editable: true
However, from one of my partials, the output is Editable: indicating nil.
I’m attempting to isolate what is different about this particular view file – posting swaths of files won’t help anyone.
With this information (I know it’s not a lot), can anyone tell me why I might not be able to set local variables in a helper method?
This was a ‘stupid mistake’ on my part but I can’t entirely blame myself. Rails behaved very oddly.
editable = truecame just after this line in my code:It’s weird, I know. I was getting errors without the
:. I’ve changed the line to thisIt should do the same thing IMO, but of course doesn’t. Despite being a 1 line if, it was including the next statement which was
editable = true. This explains why it was only happening for 1 of my views as well – the only one where the statement evaluated as true.