消息闪现
消息闪现
放在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">×</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'
梦里不知身是客,一晌贪欢。