我的一个页面不断发出此错误:
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'
有些背景,我的网站2天前遇到了502坏网关。我们设法重启了网站。但是,它引起了与mongodb的一些连接问题。我们重启数据库后解决了这个问题。但是,这一页继续遇到上述错误。这从未发生过。任何人都可以帮忙吗?
答案 0 :(得分:2)
第18行执行前look.image.url(:thumb)
的值是多少?这就是抛出错误的地方,它是我看到+
我会检查你的数据,看看崩溃是否导致数据丢失,特别是该方法所需的数据
答案 1 :(得分: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>