Add flash messages
This commit is contained in:
parent
bac93f93a0
commit
9632b9221b
4 changed files with 25 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
class FriendshipsController < ApplicationController
|
class FriendshipsController < ApplicationController
|
||||||
|
before_action :require_login
|
||||||
before_action :set_friendship, only: [:show, :destroy]
|
before_action :set_friendship, only: [:show, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,2 +1,16 @@
|
||||||
module ApplicationHelper
|
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
|
end
|
||||||
|
|
9
app/views/application/_flash_messages.html.erb
Normal file
9
app/views/application/_flash_messages.html.erb
Normal 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">×</span>
|
||||||
|
<span class="sr-only">Close</span>
|
||||||
|
</button>
|
||||||
|
<%= message %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -35,6 +35,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
<%= render 'flash_messages', flash: flash %>
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue