1
0
Fork 0

Add flash messages

This commit is contained in:
Andrew Tomaka 2014-10-15 13:50:58 -04:00
parent bac93f93a0
commit 9632b9221b
4 changed files with 25 additions and 0 deletions

View File

@ -1,4 +1,5 @@
class FriendshipsController < ApplicationController
before_action :require_login
before_action :set_friendship, only: [:show, :destroy]
def index

View File

@ -1,2 +1,16 @@
module ApplicationHelper
def bootstrap_class_for(flash_type)
bootstrap_classes[flash_type] || flash_type.to_s
end
private
def bootstrap_classes
{
'alert' => 'alert-warning',
'error' => 'alert-danger',
'notice' => 'alert-info',
'success' => 'alert-success'
}
end
end

View File

@ -0,0 +1,9 @@
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in" %>
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<%= message %>
</div>
<% end %>

View File

@ -35,6 +35,7 @@
</div>
<div class="container">
<%= render 'flash_messages', flash: flash %>
<%= yield %>
</div>