1

我刚刚完成了 Hartl 的 RoR 教程的第 7 章。所有 Spec 测试都通过了,应用程序在 localhost 上按预期运行。然而,该应用程序在 Heroku 上崩溃了。日志没有任何意义。根据 Heroku 警告消息的建议,我将 Ruby 版本明确设置为 1.9.3,但这并没有什么区别。在 Heroku 上运行

Ruby -v 给我 1.9.3,日志建议 1.9.1

不确定这是发布日志的正确方法,但以下是 Heroku 日志的转储:


> 2013-06-30T16:52:30.721129+00:00 app[web.1]: => Booting WEBrick
> 2013-06-30T16:52:30.829645+00:00 app[web.1]:  from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in
> `load_dependency' 2013-06-30T16:52:30.828830+00:00 app[web.1]: Exiting
> 2013-06-30T16:52:30.829645+00:00 app[web.1]:  from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in
> `require' 2013-06-30T16:52:30.829645+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in
> `block in require' 2013-06-30T16:52:30.829645+00:00 app[web.1]:
> /app/app/models/user.rb:1:in `<top (required)>': superclass mismatch
> for class User (TypeError) 2013-06-30T16:52:30.829645+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:359:in
> `require_or_load' 2013-06-30T16:52:30.829840+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in
> `require_dependency' 2013-06-30T16:52:30.829645+00:00 app[web.1]:
>   from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in
> `require' 2013-06-30T16:52:30.830407+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:438:in
> `each' 2013-06-30T16:52:30.829645+00:00 app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:313:in
> `depend_on' 2013-06-30T16:52:30.830407+00:00 app[web.1]:  from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:436:in
> `each' 2013-06-30T16:52:30.830407+00:00 app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:436:in
> `eager_load!' 2013-06-30T16:52:30.830407+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:439:in
> `block (2 levels) in eager_load!' 2013-06-30T16:52:30.830565+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/finisher.rb:53:in
> `block in <module:Finisher>' 2013-06-30T16:52:30.830407+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:438:in
> `block in eager_load!' 2013-06-30T16:52:30.830565+00:00 app[web.1]:
>   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in
> `block in run_initializers' 2013-06-30T16:52:30.830565+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in
> `run_initializers' 2013-06-30T16:52:30.830565+00:00 app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in
> `run' 2013-06-30T16:52:30.830565+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in
> `each' 2013-06-30T16:52:30.830565+00:00 app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in
> `instance_exec' 2013-06-30T16:52:30.830565+00:00 app[web.1]:  from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in
> `initialize!' 2013-06-30T16:52:30.830700+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in
> `initialize' 2013-06-30T16:52:30.830700+00:00 app[web.1]:     from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in
> `instance_eval' 2013-06-30T16:52:30.830565+00:00 app[web.1]:  from
> /app/config.ru:3:in `require' 2013-06-30T16:52:30.830700+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in
> `eval' 2013-06-30T16:52:30.830565+00:00 app[web.1]:   from
> /app/config/environment.rb:5:in `<top (required)>'
> 2013-06-30T16:52:30.830700+00:00 app[web.1]:  from /app/config.ru:3:in
> `block in <main>' 2013-06-30T16:52:30.830565+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in
> `method_missing' 2013-06-30T16:52:30.830700+00:00 app[web.1]:     from
> /app/config.ru:in `new' 2013-06-30T16:52:30.830838+00:00 app[web.1]:
>   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:55:in
> `block in <top (required)>' 2013-06-30T16:52:30.830838+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in
> `start' 2013-06-30T16:52:30.830700+00:00 app[web.1]:  from
> /app/config.ru:in `<main>' 2013-06-30T16:52:30.830700+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:304:in
> `wrapped_app' 2013-06-30T16:52:30.830700+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in
> `parse_file' 2013-06-30T16:52:30.830700+00:00 app[web.1]:     from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:200:in
> `app' 2013-06-30T16:52:30.830700+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in
> `app' 2013-06-30T16:52:30.830838+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:254:in
> `start' 2013-06-30T16:52:30.830838+00:00 app[web.1]:  from
> script/rails:6:in `require' 2013-06-30T16:52:30.830838+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in
> `tap' 2013-06-30T16:52:30.830838+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in
> `<top (required)>' 2013-06-30T16:52:30.830838+00:00 app[web.1]:   from
> script/rails:6:in `<main>' 2013-06-30T16:52:32.248386+00:00
> heroku[web.1]: Process exited with status 1
> 2013-06-30T16:52:32.258303+00:00 heroku[web.1]: State changed from
> starting to crashed 2013-06-30T16:54:22+00:00 heroku[slug-compiler]:
> Slug compilation started 2013-06-30T16:55:15.220931+00:00 heroku[api]:
> Deploy b5a74ad by osman.uk.oa@gmail.com
> 2013-06-30T16:55:15.263331+00:00 heroku[api]: Release v12 created by
> osman.uk.oa@gmail.com 2013-06-30T16:55:15.300675+00:00 heroku[api]:
> Deploy b5a74ad by osman.uk.oa@gmail.com
> 2013-06-30T16:55:15.493971+00:00 heroku[web.1]: State changed from
> crashed to starting 2013-06-30T16:55:15+00:00 heroku[slug-compiler]:
> Slug compilation finished 2013-06-30T16:55:17.697516+00:00
> heroku[web.1]: Starting process with command `bundle exec rails server
> -p 48620` 2013-06-30T16:55:19.476876+00:00 app[web.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 <top (required)> at /app/config/environment.rb:5)
> 2013-06-30T16:55:19.476876+00:00 app[web.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 <top (required)> at /app/config/environment.rb:5)
> 2013-06-30T16:55:20.731749+00:00 app[web.1]: => Booting WEBrick
> 2013-06-30T16:55:20.731749+00:00 app[web.1]: => Call with -d to detach
> 2013-06-30T16:55:20.731749+00:00 app[web.1]: => Rails 3.2.13
> application starting in production on http://0.0.0.0:48620
> 2013-06-30T16:55:20.731749+00:00 app[web.1]: => Ctrl-C to shutdown
> server 2013-06-30T16:55:20.731749+00:00 app[web.1]: Connecting to
> database specified by DATABASE_URL 2013-06-30T16:55:20.815078+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in
> `require' 2013-06-30T16:55:20.814340+00:00 app[web.1]: Exiting
> 2013-06-30T16:55:20.815078+00:00 app[web.1]:  from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:438:in
> `each' 2013-06-30T16:55:20.815078+00:00 app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:313:in
> `depend_on' 2013-06-30T16:55:20.815078+00:00 app[web.1]:  from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in
> `require' 2013-06-30T16:55:20.815078+00:00 app[web.1]:
> /app/app/models/user.rb:1:in `<top (required)>': superclass mismatch
> for class User (TypeError) 2013-06-30T16:55:20.815078+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in
> `block in require' 2013-06-30T16:55:20.815078+00:00 app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:359:in
> `require_or_load' 2013-06-30T16:55:20.815078+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in
> `require_dependency' 2013-06-30T16:55:20.815078+00:00 app[web.1]:
>   from
> /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in
> `load_dependency' 2013-06-30T16:55:20.815450+00:00 app[web.1]:    from
> /app/config.ru:3:in `require' 2013-06-30T16:55:20.815283+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in
> `run' 2013-06-30T16:55:20.815283+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in
> `block in run_initializers' 2013-06-30T16:55:20.815283+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in
> `each' 2013-06-30T16:55:20.815078+00:00 app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:439:in
> `block (2 levels) in eager_load!' 2013-06-30T16:55:20.815283+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:436:in
> `each' 2013-06-30T16:55:20.815283+00:00 app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:436:in
> `eager_load!' 2013-06-30T16:55:20.815283+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/finisher.rb:53:in
> `block in <module:Finisher>' 2013-06-30T16:55:20.815283+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:438:in
> `block in eager_load!' 2013-06-30T16:55:20.815283+00:00 app[web.1]:
>   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in
> `run_initializers' 2013-06-30T16:55:20.815450+00:00 app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in
> `method_missing' 2013-06-30T16:55:20.815450+00:00 app[web.1]:     from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in
> `parse_file' 2013-06-30T16:55:20.815878+00:00 app[web.1]:     from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:200:in
> `app' 2013-06-30T16:55:20.815450+00:00 app[web.1]:    from
> /app/config.ru:3:in `block in <main>' 2013-06-30T16:55:20.815283+00:00
> app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in
> `instance_exec' 2013-06-30T16:55:20.815450+00:00 app[web.1]:  from
> /app/config/environment.rb:5:in `<top (required)>'
> 2013-06-30T16:55:20.815450+00:00 app[web.1]:  from /app/config.ru:in
> `<main>' 2013-06-30T16:55:20.815878+00:00 app[web.1]:     from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:254:in
> `start' 2013-06-30T16:55:20.815878+00:00 app[web.1]:  from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:55:in
> `block in <top (required)>' 2013-06-30T16:55:20.815878+00:00
> app[web.1]:   from script/rails:6:in `require'
> 2013-06-30T16:55:20.815878+00:00 app[web.1]:  from script/rails:6:in
> `<main>' 2013-06-30T16:55:20.815878+00:00 app[web.1]:     from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in
> `start' 2013-06-30T16:55:20.815283+00:00 app[web.1]:  from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in
> `initialize!' 2013-06-30T16:55:20.815450+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in
> `instance_eval' 2013-06-30T16:55:20.815878+00:00 app[web.1]:  from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in
> `app' 2013-06-30T16:55:20.815878+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:304:in
> `wrapped_app' 2013-06-30T16:55:20.815450+00:00 app[web.1]:    from
> /app/config.ru:in `new' 2013-06-30T16:55:20.815878+00:00 app[web.1]:
>   from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in
> `tap' 2013-06-30T16:55:20.815878+00:00 app[web.1]:    from
> /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in
> `<top (required)>' 2013-06-30T16:55:20.815450+00:00 app[web.1]:   from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in
> `initialize' 2013-06-30T16:55:20.815450+00:00 app[web.1]:     from
> /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in
> `eval' 2013-06-30T16:55:21.891432+00:00 heroku[web.1]: Process exited
> with status 1 2013-06-30T16:55:21.903767+00:00 heroku[web.1]: State
> changed from starting to crashed

不用说,作为一个完整的新手,日志没有什么意义,但直到第 7 章一切正常。所以这一定是我在某个地方的一个小学生错误,但我不知道如何调试错误和谷歌搜索不要给我任何“坚定”的东西。

任何建议热烈赞赏。

盎司


以下提供了指向我的存储库的链接和 User 类的详细信息:

https://github.com/OsmanAhmed/sample_app

以下是我的用户类。我确实看过这个,但看不到任何明显错误的地方:

class User < ActiveRecord::Base


 attr_accessible :name, :email, :password, :password_confirmation
  has_secure_password

  before_save { |user| user.email = user.email.downcase } 

  validates :name, presence: true, length: { maximum: 50 }
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :email, presence: true, format: {with: VALID_EMAIL_REGEX },
                    uniqueness: { case_sensitive: false }
  validates :password, presence: true, length: { minimum: 6 }
  validates :password_confirmation, presence: true
  after_validation { self.errors.messages.delete(:password_digest) }

end

4

1 回答 1

1

问题是你的 app/controllers/example_user.rb 文件,它也定义了一个User类。

在开发模式下,这个文件可能永远不会被加载——它不是 rails 期望找到用户类的地方。然而,在生产中,rails 会预先加载应用程序中的所有文件(至少是路径中的所有文件,eager_load_paths并且恰好首先加载了这个文件。

于 2013-07-01T07:13:04.110 回答