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.
Last active
August 29, 2015 13:56
-
-
Save dwayne/9305191 to your computer and use it in GitHub Desktop.
My Rails preferences.
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