Michael Hartl:第7章 - 应用程序崩溃

时间:2013-06-30 17:13:03

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

我刚刚完成了Hartl RoR教程的第7章。 所有规范测试都通过,应用程序在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

1 个答案:

答案 0 :(得分:1)

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

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