未定义的方法`eq' for nil:NilClass with rails 3 and ruby​​ Enterprise on ubuntu hardy [英] undefined method `eq' for nil:NilClass with rails 3 and ruby enterprise on ubuntu hardy

查看:37
本文介绍了未定义的方法`eq' for nil:NilClass with rails 3 and ruby​​ Enterprise on ubuntu hardy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定是什么导致了这个错误,但是因为我在乘客和控制台中遇到了这个问题,我想也许是 mysql 驱动程序有问题?在 osx/10.6 上一切正常.它不会在 Ubuntu 8.04 hardy 上运行.

I am not sure what causes this error but since I came across this issue in passenger and now in the console as well I am thinking maybe the mysql driver is the problem? Everything works as expected on osx/10.6. It just won't on Ubuntu 8.04 hardy.

我将问题归结为销毁"方法,或者当我直接调用 activerecord 实例的方法时.为什么会这样?有什么想法吗?

I nailed down the problem to either the "destroy" method or also when I call a method of an activerecord instance directly. Why is this happening? Any ideas?

系统:

  • 支持 Ubuntu 8.04.
  • ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-linux],MBARI 0x8770,Ruby 企业版 2010.02
  • rails 3.0.0-beta4
  • mysql Ver 14.12 Distrib 5.0.51a,用于 debian-linux-gnu (i486) 使用 readline 5.2

这是错误输出

root@gehege:/var/www/foobar.com/api.foobar.com/v1# rake cleanup:status_cleanup RAILS_ENV=production --trace
(in /var/www/foobar.com/api.foobar.com/v1)
** Invoke cleanup:status_cleanup (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute cleanup:status_cleanup
rake aborted!
undefined method `eq' for nil:NilClass
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/persistence.rb:76:in `destroy'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/locking/optimistic.rb:110:in `destroy'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/callbacks.rb:278:in `destroy'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb:412:in `_run_destroy_callbacks'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/callbacks.rb:278:in `destroy'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:230:in `destroy'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:287:in `with_transaction_returning_status'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:202:in `transaction'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:285:in `with_transaction_returning_status'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:230:in `destroy'
/var/www/foobar.com/api.foobar.com/v1/lib/tasks/cleanup.rake:8
/var/www/foobar.com/api.foobar.com/v1/lib/tasks/cleanup.rake:6:in `each'
/var/www/foobar.com/api.foobar.com/v1/lib/tasks/cleanup.rake:6
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/opt/ree/bin/rake:19:in `load'
/opt/ree/bin/rake:19

即使在运行 apt-get 更新/升级到最新的 hardy 软件包并重新编译 ree 和 mysql gem 之后,我也遇到了同样的错误.

Even after running an apt-get update/upgrade to the latest hardy packages and recompiling ree and the mysql gem I get the same error.

推荐答案

回答我自己的问题:经过一些研究,我发现 rails (activerecord) 需要映射到模型的表上的 id 字段.如果您使用链接表,则不需要它们 - 但对于您想要作为模型寻址的表,它们是必需的.在我的情况下,解决方案是添加

to answer my own question: after some research i found out that rails (activerecord) needs id fields on tables that are mapped to models. if you use linktables they are not needed - but for tables you want to adress as models, they are. in my case the solution was to add

set_primary_key :cal_id

其中 cal_id 是我的唯一键.

where cal_id is my unique key.

这篇关于未定义的方法`eq' for nil:NilClass with rails 3 and ruby​​ Enterprise on ubuntu hardy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆