add one def in application_helper.rb
like :
def show_flash(flash)
html = “”
if flash[:error]
html += “
#{flash[:error]}
”
end
if flash[:warning]
html + = “
#{flash[:warning]}
”
end
if flash[:notice]
html += “
#{flash[:notice]}
”
end
end
then change in view.
from
<% if flash[:error] %>
<%= flash[:error] %>
<% end %>
<% if flash[:warning] %>
<%= flash[:warning] %>
<% end %>
<% if flash[:notice] %>
<%= flash[:notice] %>
<% end %>
To
<%= show_flash(flash) %>
I hope it will help u…
Thank you
Or something like this:
def flash_messages
messages =
%w(notice warning error).each do |msg|
messages << content_tag(:div, html_escape(flash
[msg.to_sym]), :id => "flash-#{msg}") unless flash[msg.to_sym].blank?
end
messages
end
<%= flash_messages %>
JL_Smith
(JL Smith)
3
Another similar method...
def show_flash
[:notice, :warning, :message].collect do |key|
content_tag(:div, flash[key], :class => "flash_#{key}") unless
flash[key].blank?
end.join
end