类User(TypeError)的超类不匹配?

时间:2013-11-28 04:04:09

标签: ruby-on-rails ruby ruby-on-rails-3 heroku

我和Heroku有困难。我做了heroku logs并收到错误消息:

/app/app/models/user.rb:1:in `<top (required)>': superclass mismatch for class User     (TypeError)

/app/app/models/user.rb:1:in `<top (required)>': superclass mismatch for class User     (TypeError)

2013-11-28T03:39:50.220378+00:00 app[web.1]:    from    
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-
3.2.11/lib/active_support/dependencies.rb:251:in `require'
2013-11-28T03:39:50.220378+00:00 app[web.1]:    from   
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-
3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
2013-11-28T03:39:50.220378+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-
3.2.11/lib/active_support/dependencies.rb:251:in `require'
2013-11-28T03:39:50.220378+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-
3.2.11/lib/active_support/dependencies.rb:359:in `require_or_load'
2013-11-28T03:39:50.220378+00:00 app[web.1]:    from   
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-
3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
2013-11-28T03:39:50.220378+00:00 app[web.1]:    from   
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-
3.2.11/lib/active_support/dependencies.rb:313:in `depend_on'
2013-11-28T03:39:50.220378+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-
3.2.11/lib/active_support/dependencies.rb:225:in `require_dependency'
2013-11-28T03:39:50.220378+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:438:in `each'
2013-11-28T03:39:50.220557+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:436:in 
`eager_load!'
2013-11-28T03:39:50.220557+00:00 app[web.1]:    from   
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:438:in `block in 
eager_load!'
2013-11-28T03:39:50.220378+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:439:in `block (2 
levels) in eager_load!'
2013-11-28T03:39:50.220557+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/application/finisher.rb:53:in 
`block in <module:Finisher>'
2013-11-28T03:39:50.220557+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:30:in 
`instance_exec'
2013-11-28T03:39:50.220557+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
2013-11-28T03:39:50.220557+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:436:in `each'
2013-11-28T03:39:50.220557+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
2013-11-28T03:39:50.220557+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:54:in 
`run_initializers'
2013-11-28T03:39:50.220696+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
2013-11-28T03:39:50.220557+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/application.rb:136:in 
`initialize!'
2013-11-28T03:39:50.220696+00:00 app[web.1]:    from /app/config/environment.rb:5:in 
`<top (required)>'
2013-11-28T03:39:50.220696+00:00 app[web.1]:    from /app/config.ru:in `<main>'
2013-11-28T03:39:50.220696+00:00 app[web.1]:    from /app/config.ru:3:in `require'
2013-11-28T03:39:50.220557+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block   
in run_initializers'
2013-11-28T03:39:50.220696+00:00 app[web.1]:    from   
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in 
`method_missing'
2013-11-28T03:39:50.220696+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
2013-11-28T03:39:50.220696+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
2013-11-28T03:39:50.220696+00:00 app[web.1]:    from /app/config.ru:in `new'
2013-11-28T03:39:50.221093+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in 
`start' 
2013-11-28T03:39:50.220696+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
2013-11-28T03:39:50.221093+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
2013-11-28T03:39:50.221093+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
2013-11-28T03:39:50.220696+00:00 app[web.1]:    from /app/config.ru:3:in `block in 
<main>'
2013-11-28T03:39:50.221093+00:00 app[web.1]:    from   
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/commands/server.rb:46:in `app'
2013-11-28T03:39:50.221093+00:00 app[web.1]:    from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap'
2013-11-28T03:39:50.221093+00:00 app[web.1]:    from   
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
2013-11-28T03:39:50.221093+00:00 app[web.1]:    from  
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/commands.rb:55:in `block in 
<top (required)>'
2013-11-28T03:39:50.221093+00:00 app[web.1]:    from   
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/commands.rb:50:in `<top 
(required)>'
2013-11-28T03:39:50.221093+00:00 app[web.1]:    from script/rails:6:in `require'
2013-11-28T03:39:50.221093+00:00 app[web.1]:    from script/rails:6:in `<main>'
2013-11-28T03:39:51.352167+00:00 heroku[web.1]: Process exited with status 1
2013-11-28T03:39:51.375056+00:00 heroku[web.1]: State changed from starting to crashed

我无法理解为什么我收到此错误,因为我没有/models/user.rb/。是。我实际上曾经做过一次并将它删除了。

你可以给我一些建议吗?

3 个答案:

答案 0 :(得分:2)

看看

/app/app/models/user.rb

应用程序/应用程序?这是关闭的。调查你的项目源,你确实有一个user.rb文件

答案 1 :(得分:0)

我确定这个问题不适合你。但对于那些会在这里寻找解决方案的人,我只想提一个可能的原因。 我在跟踪&#34; Rails教程&#34;时遇到了这样的错误。迈克尔哈特尔。在我的情况下,我的注意力不集中 - 我已将文件 example_user.rb (来自章节4.4.5 A user class)放在应用程序的根目录中,而不是在controllers文件夹中。在我解决了这个问题之后 - Heroku的麻烦消失了。

答案 2 :(得分:0)

对于那些将来阅读本文的人:这是一个潜在的解决方案:

潜在原因是什么?

在代码的某个地方,您可能两次定义了相同的类。在这种特定情况下,可能两次两次class User被定义在两个不同的位置。在我的特殊情况下,我在测试代码库的两个不同位置具有相同的类和相同的文件名。也许您的情况也一样?运行快速grep检查可能是值得的。希望对您有帮助。