类事件(类型错误)

问题描述:

我有我的Rails应用程序的事件模型超不匹配文件具有在给定节奏上调用的resque作业。它运行良好,当我在本地运行发条和排队在单独的终端,但是当我在heroku上部署时,它失败了,因为我试图在我的clock.rb中需要environment.rb文件(我试图部署在不需要环境的heroku上但它在发条模块中引发了其他问题)。我不明白的部分是为什么它只是失败event.rb?如果它在heroku上失败了,它也应该在本地失败。类事件(类型错误)

错误的样子:

2017-06-02T06:25:24.578369+00:00 app[clock.1]: /app/app/models/event.rb:1:in `<top (required)>': superclass mismatch for class Event (TypeError) 
2017-06-02T06:25:24.578383+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `require' 
2017-06-02T06:25:24.578384+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `block in require' 
2017-06-02T06:25:24.578385+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:259:in `load_dependency' 
2017-06-02T06:25:24.578385+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `require' 
2017-06-02T06:25:24.578389+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:380:in `block in require_or_load' 
2017-06-02T06:25:24.578389+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:37:in `block in load_interlock' 
2017-06-02T06:25:24.578390+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies/interlock.rb:12:in `block in loading' 
2017-06-02T06:25:24.578391+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/concurrency/share_lock.rb:150:in `exclusive' 
2017-06-02T06:25:24.578392+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies/interlock.rb:11:in `loading' 
2017-06-02T06:25:24.578393+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:37:in `load_interlock' 
2017-06-02T06:25:24.578393+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:358:in `require_or_load' 
2017-06-02T06:25:24.578397+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:336:in `depend_on' 
2017-06-02T06:25:24.578398+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:252:in `require_dependency' 
2017-06-02T06:25:24.578399+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!' 
2017-06-02T06:25:24.578400+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:475:in `each' 
2017-06-02T06:25:24.578400+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:475:in `block in eager_load!' 
2017-06-02T06:25:24.578401+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:473:in `each' 
2017-06-02T06:25:24.578402+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:473:in `eager_load!' 
2017-06-02T06:25:24.578402+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:354:in `eager_load!' 
2017-06-02T06:25:24.578403+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/application/finisher.rb:59:in `each' 
2017-06-02T06:25:24.578404+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>' 
2017-06-02T06:25:24.578404+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/initializable.rb:30:in `instance_exec' 
2017-06-02T06:25:24.578405+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/initializable.rb:30:in `run' 
2017-06-02T06:25:24.578405+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/initializable.rb:55:in `block in run_initializers' 
2017-06-02T06:25:24.578406+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each' 
2017-06-02T06:25:24.578407+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' 
2017-06-02T06:25:24.578407+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from' 
2017-06-02T06:25:24.578408+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component' 
2017-06-02T06:25:24.578410+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each' 
2017-06-02T06:25:24.578411+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `call' 
2017-06-02T06:25:24.578411+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component' 
2017-06-02T06:25:24.578412+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each' 
2017-06-02T06:25:24.578413+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each' 
2017-06-02T06:25:24.578414+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/initializable.rb:54:in `run_initializers' 
2017-06-02T06:25:24.578414+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/application.rb:352:in `initialize!' 
2017-06-02T06:25:24.578416+00:00 app[clock.1]: from /app/config/environment.rb:5:in `<top (required)>' 
2017-06-02T06:25:24.578417+00:00 app[clock.1]: from /app/config/clock.rb:2:in `require_relative' 
2017-06-02T06:25:24.578417+00:00 app[clock.1]: from /app/config/clock.rb:2:in `<top (required)>' 
2017-06-02T06:25:24.578420+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/clockwork-0.2.4/bin/clockwork:13:in `require' 
2017-06-02T06:25:24.578421+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/clockwork-0.2.4/bin/clockwork:13:in `<top (required)>' 
2017-06-02T06:25:24.578421+00:00 app[clock.1]: from /app/vendor/bundle/bin/clockwork:17:in `load' 
2017-06-02T06:25:24.578422+00:00 app[clock.1]: from /app/vendor/bundle/bin/clockwork:17:in `<main>' 
+0

你可以尝试在那里粘贴一个调试行,看看是否已经定义了“事件”?看起来你有定义冲突。 –

+0

你可以显示你的clock.rb文件吗? –

+0

这个错误意味着'Event'类被定义在别的地方。也许你正在使用一些宝石? – katafrakt

我跑进了完全相同的错误和情况 - 红宝石,铁轨,发条。它只发生在生产中。我的解决方案是简单地将我的事件类重命名为external_event,一旦我做到了,那么一切都正常工作。充其量,这是一个糟糕的解决方案,但我认为这是因为需要/包含结构,发条依赖于它有效地将其内部名称空间带入应用程序本身。