I created a helper in application_helper to show my flash messages. The code is based on code I found on Stack Overflow, with my modifications:
def show_flash
flash_names = [:notice, :warning, :message, :error]
flash_html = ''
for name in flash_names
if flash[name]
flash_html = flash_html + "<div class=\"#{name}\">#{flash[name]}</div>"
end
flash[name] = nil;
end
flash_html
end
When I run this, instead of getting the flash message on my page, I get the actual html that my show_flash helper generated, including all the markup:
<div class="notice">Item was successfully updated.</div>
My application.html.erb file looks like this:
<!DOCTYPE html>
<html>
<head>
<title>My Application</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<h1 align="center">Welcome to XYZ Application</c></h1>
<%= show_flash %>
<%= yield %>
</body>
</html>
What am I doing wrong?