遗留 Ruby on Rails 2.3 项目在这里。收到以下错误:
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
提取的源代码(在 #122 行附近):
119: <%= link_to 'Printable', { :action => 'print', :id => @incident.id }, { :target => '_blank', :class => "button" } %>
120: <% if isviewable?(@incident) %>
121:
122: <%= link_to "Pictures (#{@incident.pictures.count})", incident_pictures_path(@incident), :class => "button" %>
123: <%= link_to "Suspects (#{@incident.suspects.count})", incident_suspects_path(@incident), :class => "button" %>
124: <%= link_to "Notes (#{@incident.notes.count})", incident_notes_path(@incident), :class => "button"%>
125: <%= link_to "Cars (#{@incident.cars.count})", incident_cars_path(@incident), :class => "button" %>
有什么想法吗?谢谢。
编辑:删除第 122 行修复了异常,但如果该记录有,我可能需要显示一张图片,所以我不能只删除该功能。
编辑2:应用程序跟踪下的异常页面中也有这一行:
/usr/local/rvm/gems/ruby-1.8.7-p371/gems/paperclip-2.3.0/lib/paperclip.rb:303:in `validates_attachment_content_type'
我的回形针插件可能有错误吗?