为什么我为Heroku托管的全新应用程序收到应用程序错误错误页面?

时间:2014-07-27 03:14:13

标签: ruby-on-rails ruby git heroku

对于RoR来说,我几乎是全新的。

我正在关注一个视频教程来构建我自己的基于Web的应用程序,然后我完成了这个步骤: git push heroku master

在git bash中,它出现了一个错误,声称它无法编译ruby。现在,它说它已启动并部署,但我的应用程序的页面上仍然存在相同的错误,http://infinite-mountain-6131.herokuapp.com/

任何想法?如果需要,我可以添加文件。

请求的文件:

app / config / application.rb来自我的评论

require File.expand_path('../boot', __FILE__)

require 'rails/all'

# config/application.rb
config.assets.initialize_on_precompile = false

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Myrubyblog
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de
  end
end

我的错误中提到的第6行是config.assets.initialize,我将其放在第5行,以解决我的问题。

当我按照建议(heroku run rake db:migrate)运行迁移时会发生这种情况

Running 'rake db:migrate' attached to terminal... up, run.6274
rake aborted!
NameError: undefined local variable or method 'config' for main:Object
/app/config/application.rb:6:in '<top <required>>'
/app/Rakefile:4:in 'require'
/app/Rakefile:4:in '<top <required>'
<See full trace by running task with --trace>

1 个答案:

答案 0 :(得分:1)

通常,在Heroku上托管Rails应用程序时可能会出现两种类型的错误:

Heroku错误

enter image description here

-

Rails错误

enter image description here

-

错误

两者之间的区别很重要 - rails错误只会在您的操作环境实际上正在运行时发生。你的Rails应用程序。如果您的操作环境/ Heroku无法正确加载,则会出现Heroku错误

您遇到的问题肯定是 Heroku 问题 - 通常由缺少db连接创建的问题。解决此问题的方法是确保您的应用程序具有运行所有必需品 - 最值得注意的是正确的db

您最好使用以下内容:

$ heroku run rake db:migrate

但是,我很欣赏这不是你唯一的问题


Heroku部署

正如你所说,你是一个初学者&#34;对ROR,让我给你一些想法

首先,当你在这里写一个问题时,它有助于尽可能多地泄露信息 - 通常来自日志或任何其他特定的错误处理机制

其次,您希望确保实现运行应用程序所需的一切。最值得注意的是,当你提到Heroku cannot compile the Ruby application时,你需要提供为什么这样的信息 - 那里可能是gem冲突(SQLite3)或类似的

第三,您需要确保已迁移数据库。这是&#34; Heroku错误&#34;显示 - 部署您的Rails应用程序并不意味着您在本地进行的迁移将持续存在 - 您需要确保根据需要更新db,这可以通过以下方式完成:

$ heroku run rake db:migrate