消息闪现

消息闪现

放在ApplicationHelper.rb中。在页面面中 <%= nitice_message %>

def notice_message
   flash_messages = []
      flash.each do |type, message|
        type = :success if type.to_sym == :notice
        type = :danger  if type.to_sym == :alert
        text = content_tag(:div, link_to(raw('<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'), '#', :class => 'close', 'data-dismi  ss' => 'alert') + message, class: "alert alert-#{type}")
        flash_messages << text if message
    end
    flah.clear
    flash_messages.join("\n").html_safe
    end

在控制器中:

redirect_to root_url,notice:'hello'
posted @ 2018-01-21 10:27  -梦里不知身是客  阅读(215)  评论(0编辑  收藏  举报