Skip to content

Instantly share code, notes, and snippets.

@bogardpd
Created April 23, 2017 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogardpd/a3be6a88305e73d80bfb2912bb3b3919 to your computer and use it in GitHub Desktop.
Save bogardpd/a3be6a88305e73d80bfb2912bb3b3919 to your computer and use it in GitHub Desktop.
# app/helpers/application_helper.rb
def render_messages
order = [:error, :warning, :success, :info]
@messages ||= []
@messages.concat(flash.map{|k,v| {type: k.to_sym, text: v}}) if flash
@messages.sort_by{|m| order.index(m[:type]) || order.length}
.map{|m| render_message(m[:type], m[:text]) }.join.html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment