2013-01-09 62 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