I have this at the beginning of a rails view partial:
<% enabled = true unless defined?(enabled) %>
This is to handle cases when the calling view doesn't pass in the enabled
local, by setting a default.
But enabled
doesn't get set to true.
I'm aware that of the construct enabled ||= true
, but I can't use that here because of the possibility that the passed-in value is false
. That would get overwritten with true
.