0

在我的 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" %>&nbsp;<%= 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'

我很乐意在这里提供解决方案。提前致谢。

4

0 回答 0