1

I am getting this error pretty regularly, but it also seems to be pretty randomly.

C:/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/core_ext/object/to_json.rb:20:in `to_json'

This is occurring sporadically when calling to_json on a hash, for example:

{:@i=>18}.to_json

Anyone run across this before? It's strange and can't find much on the internets related.

4

1 回答 1

4

我在使用线程时得到了这个(但我没有使用 activerecord 而是 SimpleRecord(亚马逊的数据库)。解决方案是首先使用 .to_json 而不使用线程:

MyFantasticModel.first.to_json 
# and then run the threaded stuff
@threads << Thread.new {...
于 2011-03-25T12:06:13.067 回答