开发者

:alert does not work; :notice does

For some reason my :alert does not work, whereas :notice works just fine.

<% if notice %>
    <p id="notice" ><%= notice %></p> 
<% elseif alert %>
    <p id="alert" ><%= alert %></p> 
<% end %>
<%= yield %>

Anyone know why :alert is not working? I'm using Rails 3.1.0.RC5

EDIT: Found a more effective method thanks to Reuben Malla开发者_运维技巧by for display all notices and alerts.

<%- flash.each do |k, v| %>
    <div id="<%= k %>"><%= v %></div>
<% end %> 
<%= yield %>


To make sure you display all flash messages:

<%- flash.each do |k, v| %>
  <div id="<%= k %>"><%= v %></div>


Are these for flash? If so, do they work when explicitly calling flash?

<% if flash[:notice] %>
    <p id="notice" ><%= flash[:notice] %></p> 
<% elsif flash[:alert] %>
    <p id="alert" ><%= flash[:alert] %></p> 
<% end %>
<%= yield %>

If not, it could be an issue in your controller. Please post the code that is setting the :notice and :alerts.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜