Skip to content

Instantly share code, notes, and snippets.

@raketbizdev
Last active March 8, 2018 19:42
Show Gist options
  • Save raketbizdev/20cd3ac0f925c107ae4e289b2fa2e23d to your computer and use it in GitHub Desktop.
Save raketbizdev/20cd3ac0f925c107ae4e289b2fa2e23d to your computer and use it in GitHub Desktop.
Updated Rails flash messages using Bootstrap 4 from https://gist.github.com/roberto/3344628
<% flash.each do |type, message| %>
<div class="alert alert-<%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
<%= render partial: "layouts/flash_messages", flash: flash %>
class ApplicationController < ActionController::Base
add_flash_types :success, :warning, :info, :error
end
module ApplicationHelper
def bootstrap_class_for flash_type
case flash_type
when :success
"alert-success"
when :error
"alert-error"
when :alert
"alert-block"
when :info
"alert-info"
else
flash_type.to_s
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment