Skip to content

Instantly share code, notes, and snippets.

@kawahiro311
Forked from roberto/_flash_messages.html.erb
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save kawahiro311/52d5f4ce0f7849454b32 to your computer and use it in GitHub Desktop.

Select an option

Save kawahiro311/52d5f4ce0f7849454b32 to your computer and use it in GitHub Desktop.
RailsでTwitterBootstrapを使ったflashメッセージ
<% flash.each do |type, message| %>
<div class="alert <%= flash_class_for(type) %>" role="alert">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
<%= render partial: "shared/flashes", flash: flash %>
module ApplicationHelper
def flash_class_for flash_type
case flash_type
when 'success' then 'alert-success'
when 'error' then 'alert-danger'
when 'alert' then 'alert-warning'
when 'notice' then 'alert-info'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment