TypeError:无法在Heroku中转储匿名类Class

时间:2012-10-11 00:11:06

标签: ruby-on-rails ruby postgresql nokogiri

我正在使用heroku的scheduler addon运行rake任务。它在开发中工作,但在生产中失败。这是heroku日志中的堆栈跟踪:

2012-10-10T23:30:23+00:00 heroku[api]: Starting process with command `bundle exec rake deals --trace` by scheduler@addons.heroku.com
2012-10-10T23:30:29+00:00 heroku[scheduler.1]: Starting process with command `bundle exec rake deals --trace`
2012-10-10T23:30:30+00:00 heroku[scheduler.1]: State changed from starting to up
2012-10-10T23:30:56+00:00 app[scheduler.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from  at /app/Rakefile:7)
2012-10-10T23:30:56+00:00 app[scheduler.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from  at /app/Rakefile:7)
2012-10-10T23:30:56+00:00 app[scheduler.1]: ** Invoke deals (first_time)
2012-10-10T23:30:56+00:00 app[scheduler.1]: ** Invoke environment (first_time)
2012-10-10T23:30:56+00:00 app[scheduler.1]: ** Invoke documents:remove_documents (first_time)
2012-10-10T23:30:56+00:00 app[scheduler.1]: ** Execute environment
2012-10-10T23:31:00+00:00 app[scheduler.1]: ** Execute documents:remove_documents
2012-10-10T23:31:01+00:00 app[scheduler.1]: ** Invoke environment 
2012-10-10T23:31:01+00:00 app[scheduler.1]: ** Execute documents:add_documents
2012-10-10T23:31:01+00:00 app[scheduler.1]: ** Invoke documents:add_documents (first_time)
2012-10-10T23:31:18+00:00 app[scheduler.1]: TypeError: can't dump anonymous class Class: INSERT INTO "documents" ("body", "created_at", "merchant_id", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `map'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `block in to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:6:in `to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `each'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `node_export'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `block (3 levels) in to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `each'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `map'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck.rb:401:in `emit'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `block in to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `each'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck.rb:401:in `call'
2012-10-10T23:31:18+00:00 app[scheduler.1]: rake aborted!
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `block (2 levels) in to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:15:in `to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `block (2 levels) in to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:665:in `block in exec_query'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `add'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `block (3 levels) in to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `map'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `block in to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck.rb:401:in `emit'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1168:in `block in exec_cache'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `add'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `block (2 levels) in to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck.rb:401:in `quick_emit'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck.rb:119:in `dump'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `block (3 levels) in to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck.rb:401:in `emit'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/relation.rb:66:in `insert'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:15:in `to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `add'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck.rb:401:in `call'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:15:in `to_yaml'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1167:in `exec_cache'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/timestamp.rb:57:in `create'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:468:in `type_cast'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:403:in `_run__2196213232156732911__create__4012089935340517551__callbacks'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/callbacks.rb:268:in `create'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `node_export'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck.rb:401:in `call'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/quoting.rb:74:in `type_cast'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/callbacks.rb:264:in `block in create_or_update'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/callbacks.rb:268:in `block in create'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck.rb:401:in `quick_emit'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck.rb:401:in `quick_emit'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `node_export'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in `exec_query'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:63:in `exec_insert'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/callbacks.rb:264:in `create_or_update'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/validations.rb:50:in `save'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/persistence.rb:366:in `create'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1167:in `map'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/persistence.rb:347:in `create_or_update'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/persistence.rb:84:in `save'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:425:in `_run__2196213232156732911__save__4012089935340517551__callbacks'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/attribute_methods/dirty.rb:22:in `save'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:241:in `block (2 levels) in save'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208:in `transaction'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:241:in `block in save'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:240:in `save'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/persistence.rb:45:in `create'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/app/models/worker.rb:54:in `block in add_documents'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/app/models/worker.rb:27:in `each'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/app/models/worker.rb:27:in `add_documents'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/lib/tasks/scrape.rake:9:in `block (2 levels) in '
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `'
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `load'
2012-10-10T23:31:18+00:00 app[scheduler.1]: Tasks: TOP => deals => documents:add_documents
2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `'
2012-10-10T23:31:20+00:00 heroku[scheduler.1]: Process exited with status 1
2012-10-10T23:31:20+00:00 heroku[scheduler.1]: State changed from up to complete

这是我试图插入数据库的模型方法:

def self.add_documents
  body = Nokogiri::HTML(open('http://www.someurl.com')).to_s.to_my_utf8
  merchant_id = Merchant.find(1)
  Document.create(:merchant_id => merchant_id, :body => body)
end

# config/initializers/string.rb
require 'iconv'

class String
  def to_my_utf8
    ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', self + ' ')[0..-2]
  end
end

我很乐意帮助解决这个问题!

编辑:更新了完整的堆栈跟踪。

0 个答案:

没有答案