1

我正在开发一个用 Ruby 自定义编写的小型 CMS,该网站使用 Mongrel 运行。不幸的是,我对 Ruby 一点也不熟悉。网站的一部分最近停止工作(与任何更新无关,所以我不确定是什么原因)

检查 rails 日志中的“production.log”显示以下内容:

ActionView::TemplateError (undefined method `name' for nil:NilClass) on line #25 of app/views/static/frontpage.rhtml: 22: <% Tabloid.find(:all, :limit => 4, :order = >'date DESC').each do |tabloid|%> 23: 24: <%= link_to tabloid.title, :controller => 'tabloid', :action => 'show', :id => tabloid.id % > 25:

<%= tabloid.date.strftime("%d of %B, %Y") %> By: <%= Profile.find(:first, :conditions => [ "user_id = ?", tabloid.user_id]) .name %> <%= Profile.find(:first, :conditions => [ "user_id = ?", tabloid.user_id]).surname %>

26:

<%= RedCloth.new(truncate(tabloid.texto, 250)).to_html %>

27: <% if tabloid.texto.size > 250 %> 28:

<%= link_to "阅读更多 >", :controller => 'tabloid', :action => 'show', :id => tabloid.id %>

app/views/static/frontpage.rhtml:25
app/views/static/frontpage.rhtml:22:in `each'
app/views/static/frontpage.rhtml:22
/usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in

send' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in 渲染'/usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_view/template.rb:73:in render_template' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_view/base.rb:256:in 渲染'/usr/local/rubygems/gems/gems/actionpack-2.2.2/lib /action_view/base.rb:367:in _render_with_layout' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_view/base.rb:254:in render' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_controller/base.rb:1174:in render_for_file' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_controller/base.rb:896:in render_without_benchmark' /usr/local/rubygems/gems /gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in render' /usr/local/rubygems/gems/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in realtime' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in render' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_controller/base.rb:868:in render_without_benchmark' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in render' /usr/local/rubygems/gems/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in realtime' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib /action_controller/benchmarking.rb:51: 在render' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in dispatch' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:in dispatch_cgi' /usr/local/rubygems/gems/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:39:in dispatch' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib /mongrel/rails.rb:76:in process' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in synchronize' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in process' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel.rb:159:inprocess_client' /usr/local/rubygems/gems /gems/mongrel-1.1.5/lib/mongrel.rb:158:in each' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel.rb:158:inprocess_client' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel.rb:285:in run' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel.rb:285:ininitialize' /usr /local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel.rb:285:in new' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in run' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel/configurator.rb :281: each' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in 运行中'

等等。 Mongrel 日志实际上已经有一段时间没有更新了。关于问题是什么或我应该在哪里继续挖掘的任何指示?

4

1 回答 1

1

Profile.find(:first, :conditions => [ "user_id = ?", tabloid.user_id])查询返回nil,因此他无法name对其执行

于 2013-01-09T14:52:28.980 回答