在我的rails应用程序中使用以下这些行导致ActionTemplate:Error(堆栈级别太深)。一切都运行正常,使用相同的代码,突然应用程序开始抛出此错误。
<% if (not flash[:notice].nil? and not flash[:notice].empty?) or (not flash[:warning].nil? and not flash[:warning].empty?) %>
<center>
<div style="background-color:lightyellow; border: 1px solid gold; width: 95%; padding: 3px; text-align: left;">
<font color=green>
<i>
<b>
<%= flash[:notice] %>
<% if !flash[:warning].blank? %>
<%= "<BR/>" if !flash[:notice].blank?%>
<%= image_tag "warning.ico", :size => "32x32" %> <%= flash[:warning] %>
<% end %>
</b>
</i>
</font>
<br/>
</div>
</center>
<% flash[:notice] = flash[:warning] = "" %>
<% end %>
开发日志中抛出的错误是
ActionView::TemplateError (stack level too deep) on line #182 of app/views/layouts/loggedin.rhtml:
179: </font>
180: <br/>
181: </div>
182: <% if (not flash[:notice].nil? and not flash[:notice].empty?) or (not flash[:warning].nil? and not flash[:warning].empty?) %>
183: <center>
184: <div style="background-color:lightyellow; border: 1px solid gold; width: 95%; padding: 3px; text-align: left;">
185: <font color=green>
app/views/layouts/loggedin.rhtml:182:in `_run_rhtml_app47views47layouts47loggedin46rhtml'
app/controllers/testcases_controller.rb:1337:in `view'
我很高兴在这里找到解决方案。提前谢谢。