【问题标题】:Obcure rendering error in Ruby on RailsRuby on Rails 中的模糊渲染错误
【发布时间】:2012-12-23 15:40:29
【问题描述】:

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

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

ActionView::TemplateError(nil:NilClass 的未定义方法“名称”) 在 app/views/static/frontpage.rhtml 的第 25 行:22: 4, :order =>'date DESC').each |tabloid|%> 23:24: 'tabloid', :action => 'show', :id => tabloid.id %> 25:

By: [ "user_id = ?", tabloid.user_id]).name %> [ "user_id = ?", tabloid.user_id]).surname %>

26:

27: 250 %> 28:

", :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 render' /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 render' /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:in 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 同步' /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:in each' /usr/local/rubygems/gems/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in run'

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

【问题讨论】:

    标签: ruby-on-rails ruby mongrel


    【解决方案1】:

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

    【讨论】:

    • 谢谢,这些ID确实有问题,这让我走上了正轨。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-24
    • 2010-11-10
    • 2017-05-07
    • 2011-05-18
    • 1970-01-01
    相关资源
    最近更新 更多