I use this code to display flash messages in Rails 3.2.1 apps (well, I did):
<% flash.each do |name, msg| %>
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
<%= msg %>
</div>
<% end %>
But I get nothing. So I put <%= debug flash %> to see what I was getting back after an update and I get this:
--- !ruby/object:ActionDispatch::Flash::FlashHash
used: !ruby/object:Set
hash: {}
closed: false
flashes: {}
now:
How to I do the same thing?
The code I use for displaying flash messages and alerts is:
<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :class => "flash flash_#{name}" %>
<% end %>
But if your flash hash is empty, it's not going to display anything. Are you sure you're setting your flash hash properly?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With