1

我的一个页面不断出现此错误:

ActionView::Template::Error (undefined method `+' for nil:NilClass):
    15:   <div class="look_list">
    16:     <% collection.each do |look| %>
    17:       <div class="look_book" id="<%= look.content_id %>">
    18:         <% thumbnail_image = (look.processing? ? "/assets/processing_placeholder.gif" : (look.image.url(:thumb) + "?#{look.updated_at.to_i}")) %>
    19:         <%= image_tag thumbnail_image || "/assets/processing_placeholder.gif",:class=> "look_image", :size => "118x118" %>
    20:         <script type="text/javascript">
    21:
  app/views/looks/index.html.erb:18:in `block in _app_views_looks_index_html_erb__3409922204803071014_68666020'
  app/views/looks/index.html.erb:16:in `_app_views_looks_index_html_erb__3409922204803071014_68666020'

一些背景,我的网站两天前进入了 502 bad gateway。我们设法重新启动了站点。但是,它导致了与 mongodb 的一些连接问题。这在我们重新启动数据库后得到解决。但是,这一页不断出现上述错误。这是以前从未发生过的。任何人都可以帮忙吗?

4

2 回答 2

2

look.image.url(:thumb)第 18 行执行之前的值是多少?那是引发错误的地方,这是我看到的唯一地方+

我会检查您的数据,看看崩溃是否导致某处数据丢失,特别是该方法所需的数据

于 2013-02-08T04:11:36.663 回答
0

试试这样的东西......

<div class="look_list">
        <% collection.each do |look| %>
         <div class="look_book" id="<%= look.content_id %>">
            <% thumbnail_image = look.image.url(:thumb) unless look.processing? %>
                  <% thumbnail_image.nil? ? "/assets/processing_placeholder.gif" : (look.image.url(:thumb) + "?#{look.updated_at.to_i}") %>
            <%= image_tag thumbnail_image ,:class=> "look_image", :size => "118x118" %>
        </div>
        <% end %>
</div>
于 2013-02-08T04:22:29.840 回答