I have a flash_helper that I inconveniently downloaded from some web tutorial, which is now coming back to whack me on the head. On the good side, I'm sure the many talented coders here will find this easy. :)
# application_helper
def flash_helper
[:notice, :warning, :message].map { |f| content_tag(:div, flash[f], :class => f) if flash[f] }
end
This code, combined with <%= flash_helper %> in my views, is leading to the following html code generated:
["<div class=\"notice\">Your account has been reactivated.</div>", nil, nil]
...which renders as this rather unattractive string in the view itself:
["<div class=\"notice\">Your account has been reactivated.</div>", nil, nil]
How do I rewrite the code to sort this out?
[nil, nil, nil]
The above string is being sent to all of my views by the flash_helper code above when there is no flash. How can that code be rewritten to output nothing when there is no flash?