2013-01-09 61 views
0

我正在使用Ruby定制的一个小CMS,该网站正在使用Mongrel运行。 不幸的是我对Ruby一点都不熟悉。该网站的一部分,最近停止工作(不与任何更新或这样的连接,所以我不能确定是什么原因)Ruby on Rails中出现错误渲染错误

检查在轨日志“production.log”显示以下内容:

ActionView :: TemplateError(未定义方法名称为nil:NilClass) on line#25 of app/views/static/frontpage.rhtml:22:<% Tabloid.find(:all,:limit => 4,:order =>'date DESC')。每个都做 |小报|%> 23:24:<%= link_to tabloid.title,:controller => 'tabloid',:action =>'show',: id => tabloid.id%> 25:

<%= tabloid.date.strftime(“%d,%B,%Y”)%> <%= Profile.find(:first, :conditions => [“user_id =?”,tabloid。 。USER_ID])名称%> <%= Profile.find(:第一,:条件=> [ “USER_ID =?”, tabloid.user_id])姓%>

26:

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

27:<%如果 tabloid.texto.size> 250%> 28:

<%=的link_to “更多>”, :控制器=>“小报',: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 /本地/ RubyGems的/ gems/gems/actionpack-2.2.2/lib/action_view/base.rb:367: _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:在 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 实时' /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 实时 ' /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/dispatcher.rb:122:in 派遣' /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:在 process' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in 同步' /usr/local/ru bygems/gems/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:在 process' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel.rb:159:in process_client' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel.rb :158:在each' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel.rb:158:in process_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:in初始化' 的/ usr /本地/的rubygems /宝石/宝石/杂种-1.1.5/lib/mongrel.rb:285:在new' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in 运行' /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 运行”

等 的杂种原木居然还没有更新,在一段时间。任何问题是什么问题或我应该继续挖掘?

回答

1

Profile.find(:first, :conditions => [ "user_id = ?", tabloid.user_id])查询返回nil所以他不能在其上执行name

+0

谢谢,确实有一些错误这些ID,这给我带来了正轨。 – Lars