Chris Gibson

Rails Flash

flash[:alert] = "You must be logged in."

flash[:notice] = "Post successfully created."

Display

<p class="notice"><%= flash[:notice] %></p>
<p class="alert"><%= flash[:alert] %></p>

Styling

app/views/layouts/application.html.erb

  <%= render partial: "layouts/flash" %>

app/views/layouts/_flash.html.erb

<% flash.each do |type, message| %>
  <div>
    <%= message %>
  </div>
<% end %>