Skip to content

Instantly share code, notes, and snippets.

@dwayne
Last active August 29, 2015 13:56
Show Gist options
  • Save dwayne/9305191 to your computer and use it in GitHub Desktop.
Save dwayne/9305191 to your computer and use it in GitHub Desktop.
My Rails preferences.

About

If I find myself doing something over and over in Rails or if I come across a good best practice, then I'd document it here for future reference.

Flash

Create the file shared/_flash_message.html.erb and add the following:

<div class="flash_messages">
  <% flash.each do |key, value| %>
    <%= content_tag(:div, value, class: "flash flash_#{key}") %>
  <% end %>
</div>

In layouts/application.html.erb we render the flash messages as follows:

<%= render 'shared/flash_messages' unless flash.empty? %>

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment