2

我在销毁对象时遇到了这个问题。

NoMethodError: undefined method `substitute_at' for nil:NilClass
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activerecord-3.2.11/lib/active_record/persistence.rb:135:in `destroy'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activerecord-3.2.11/lib/active_record/locking/optimistic.rb:103:in `destroy'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activerecord-3.2.11/lib/active_record/callbacks.rb:254:in `block in destroy'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:480:in `_run__348799253__destroy__466331341__callbacks'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_destroy_callbacks'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activerecord-3.2.11/lib/active_record/callbacks.rb:254:in `destroy'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activerecord-3.2.11/lib/active_record/transactions.rb:254:in `block in destroy'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activerecord-3.2.11/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activerecord-3.2.11/lib/active_record/transactions.rb:208:in `transaction'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activerecord-3.2.11/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/activerecord-3.2.11/lib/active_record/transactions.rb:254:in `destroy'
from (irb):1
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p194@clu2/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
4

2 回答 2

2

我已经解决了这个问题,我的应用程序的关联名称之一是连接,它是活动记录 gem 中的保留字:

参见第 135 行 https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/persistence.rb

我将关联名称从连接更改为其他名称,现在一切正常。

于 2013-03-14T10:50:08.177 回答
0

我发现这是一个 Rails 问题https://github.com/rails/rails/pull/9371。我认为它现在已修复。你可以更新你的rails

于 2013-03-13T07:10:58.897 回答