<%# Rails flash messages styled for Bootstrap 3.0 %>
<% flash.each do |name, msg| %>
  <% if msg.is_a?(String) %>
    <div id="flash_message">
      <div class="alert alert-<%= name.to_s == 'notice' ? 'success' : 'danger' %>">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
        <%= content_tag :div, msg, :id => "flash_#{name}" %>
        <% if name != :persistent_alert %>
          <%= content_tag :script, :type => "text/javascript" do -%>
            setTimeout("$('#flash_message').remove();", 12000);
          <% end %>
        <% end %>
      </div>
    </div>
  <% end %>
<% end %>

<%# Rails flash messages styled for Bootstrap 3.0 %>
<% flash.each do |name, msg| %>
  <% if msg.is_a?(String) %>
    <div id="flash_message">
      <div class="alert alert-<%= name.to_s == 'notice' ? 'success' : 'danger' %>">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
        <%= content_tag :div, msg, :id => "flash_#{name}" %>
        <% if name != :persistent_alert %>
          <%= content_tag :script, :type => "text/javascript" do -%>
            setTimeout("var element = document.getElementById('flash_message'); if (element) { element.remove(); }", 12000);
          <% end %>
        <% end %>
      </div>
    </div>
  <% end %>
<% end %>

Replace jQuery remove with pure js remove As jQuery is not reliably available when this code is ran.
Replace jQuery remove with pure js remove
As jQuery is not reliably available when this code is ran.