Rewrite flash messages
This commit is contained in:
parent
6b3e57ab45
commit
3299f46ed7
2 changed files with 16 additions and 2 deletions
|
@ -1,7 +1,20 @@
|
|||
require 'digest/md5'
|
||||
module ApplicationHelper
|
||||
def bootstrap_class_for flash_type
|
||||
{ success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }[flash_type] || flash_type.to_s
|
||||
end
|
||||
|
||||
def flash_messages(opts = {})
|
||||
flash.map do |msg_type, message|
|
||||
content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type.to_sym)}") do
|
||||
content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' }) +
|
||||
content_tag(:strong, [msg_type.capitalize, "! "].join("")) +
|
||||
message
|
||||
end
|
||||
end.join().html_safe
|
||||
end
|
||||
|
||||
def get_color(user)
|
||||
require 'digest/md5'
|
||||
Digest::MD5.hexdigest(user.name)[0..5]
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
= render 'layouts/header'
|
||||
.container
|
||||
%h2= yield :title
|
||||
= render partial: 'flash'
|
||||
#flash
|
||||
= flash_messages
|
||||
= yield
|
||||
= render 'layouts/footer'
|
||||
= debug(params) if Rails.env.development?
|
||||
|
|
Loading…
Reference in a new issue