【问题标题】:Heroku rails deployment "at=error code=H10 desc="App crashed"Heroku rails 部署 "at=error code=H10 desc="App crashed"
【发布时间】:2018-06-29 12:47:15
【问题描述】:

我正在尝试在 Heroku 上部署我的 Rails 应用程序,但是我遇到了两个 h10 错误:

heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" ... dyno= connect= service= status=503 bytes= protocol=https

at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" ...  dyno= connect= service= status=503 bytes= protocol=https

正如我在其他帖子中看到的那样,我运行了heroku console

我得到了这个答案:

/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.6/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined local variable or method `acts_as_votable' for Comment (call 'Comment.connection' to establish a connection):Class (NameError)

当我在做heroku run rake db:migrate 时,我得到了这个:

rake aborted!
NameError: uninitialized constant ForestLiana`

这是我的Gemfile

source 'https://rubygems.org'

ruby '2.3.0'

gem 'rails', '4.2.6'

group :development do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end

gem 'rails_12factor'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'

gem 'jquery-rails'    
gem 'turbolinks'    
gem 'jbuilder', '~> 2.0'    
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bcrypt', '~> 3.1.7'

group :development, :test do
  gem 'byebug'
end

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
  gem 'forest_liana'
  gem 'acts_as_votable', '~> 0.10.0'
end

是gem版本的原因吗?我该如何解决这个问题?

【问题讨论】:

    标签: ruby-on-rails ruby heroku rubygems


    【解决方案1】:

    将代码部署到 Heroku 时,它不会安装在您的 Gemfile 中的 :development 组中定义的 gem,因为在生产中实际运行您的应用程序时通常不需要这些 gem。

    但是,在您的情况下,您已在开发组中添加了 acts_as_votable gem。由于您的模型依赖于它,因此您应该在 Gemfile 中的任何组之外定义它,以便始终安装它。

    检查堆栈跟踪时,您可以看到您在 Comment 类上调用的 acts_as_votable 方法在 Heroku 上不可用。这可能会提示您添加此方法的 gem 未安装或未以某种方式加载。

    【讨论】:

      猜你喜欢
      • 2015-03-01
      • 2013-03-30
      • 2019-07-02
      • 1970-01-01
      • 2020-04-28
      • 2021-10-22
      • 1970-01-01
      • 2018-04-09
      • 1970-01-01
      相关资源
      最近更新 更多