Heroku on Rails - 无效的DATABASE_URL [英] Heroku on Rails - Invalid DATABASE_URL

查看:80
本文介绍了Heroku on Rails - 无效的DATABASE_URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:一般的建议是使用 CEDAR 堆栈。



对RoR,Gems,Heroku和Git来说很新颖。以下教程: http://ruby.railstutorial.org/book/ruby-on -rails-tutorial



在本地主机上运行良好,部署到Heroku时出现 ConnectionNotEstablished错误,此处解决:
https://stackoverflow.com/questions/7542745/heroku-error-activerecordconnectionnotestablished (顺便说一句:遵循相同的教程)在将生产数据库更改为PostgreSQL (gem'pg')后,会生成另一个错误: Visting live site
$ b


应用程序发生错误,您的网页无法投放
。请稍后重试。



如果您是应用程序所有者,请查看日志以获取详细信息。


尝试过 -
Heroku应用程序崩溃,收到Invalid DATABASE URL当尝试heroku rake db:migrate -
heroku rake db:migrate

  rake中止了! 
无效DATABASE_URL

任务:TOP => db:migrate => db:load_config
(通过使用--trace运行任务来查看完整跟踪)

heroku console

 内部服务器错误

gemfile

 来源'http:/ /rubygems.org'

gem'rails','3.1.1'

group:development do
gem'rspec-rails','2.6.1 '
gem'annotate','〜> 2.4.1.beta'
gem'sqlite3'
end

group:test do
gem'rspec-rails','2.6.1'
gem'webrat','0.7.1'
gem'sqlite3'
end

group:production do
gem'pg'
end

组:资产do
gem'sass-rails','〜> 3.1.4'
gem'咖啡栏','〜> 3.1.1'
gem'uglifier','> = 1.0.3'
结束



heroku日志

  9:02 + 00:00 app [web.1 ]:from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in`run!'
9:02 +00:00应用[web.1]:从/usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in`< top(必填)>'
9:02 + 00:00 app [web.1]:from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/ thin / runner.rb:177:在`run_command'
9:02 + 00:00 app [web.1]:from /home/heroku_rack/heroku.ru:18:in`block(2 levels)in < main>'
9:02 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/ builder.rb:51:在`initialize'
9:02 + 00:00 app [web.1]:from /usr/ruby1.9.2/bin/thin:19:in`< main>'
9:02 + 00:00 app [web.1]:from /usr/ruby1.9.2/bin/thin:19:in`load'
9:03 + 00:00 heroku [web。 1]:状态从开始变为崩溃
9:04 + 00:00 heroku [ web.1]:进程已退出
1:58 + 00:00 heroku [slugc]:弹头编译开始
3:09 + 00:00 heroku [api]:通过mstefanow@gmail.com部署3dea426
3:09 + 00:00 heroku [api]:发布v7由mstefanow@gmail.com创建
3:09 + 00:00 heroku [web.1]:状态从崩溃状态更改为已创建
3:09 + 00:00 heroku [web.1]:从创建状态改为开始
3:10 + 00:00 heroku [slugc]:弹头编辑完成
3:12+ 00:00 heroku [web.1]:使用命令thin -p 44881 -e production -R /home/heroku_rack/heroku.ru start启动进程
3:15 + 00:00 app [web.1 ]:(erb):9:in`rescue in< main>'无效DATABASE_URL(RuntimeError)
3:15 + 00:00 app [web.1]:from(erb):6: < main>
3:15 + 00:00 app [web.1]:from /usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in`eval'
3:15 + 00:00 app [web.1]:从/usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in'result'
3:15 +00:00应用[web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/application/configura tion.rb:106:在`database_configuration'
3:15 + 00:00 app [web.1]中:from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1 /lib/active_support/lazy_load_hooks.rb:36:in`instance_eval'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/ activerecord-3.1.1 / lib / active_record / railtie.rb:68:在< class:Railtie>'
3:15 + 00:'应用程序[web.1]中的块(2级) /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:36:in`execute_hook'
3:15 + 00:00 app [web .1]:从/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:43:in`block in run_load_hooks'
3:15 +00:00应用[web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in`each'
3:15 + 00:00应用[web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
3:15 + 00:00 app [web.1]:fro m /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/base.rb:2190:in`< top(required)>'
3: 15 + 00:00应用[web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in`require'
3:15 + 00:00应用[web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240: in`block in require'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support /dependencies.rb:225:in`load_dependency'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1。 1 / lib / active_support / dependencies.rb:240:在'require'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems /activesupport-3.1.1/lib/active_support/dependencies.rb:489:in`load_missing_constant'
3:15 + 00:00 app [web.1]:from /app/app/models/user.rb :12:在<<顶部(必填)>'
3:15 + 00:00应用[web.1]:从/app/.bundl e / gems / ruby​​ / 1.9.1 / gems / activesupport-3.1.1 / lib / active_support / dependencies.rb:179:在`each'
3:15 + 00:00 app [web.1]中: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:179:in`const_missing'
3:15 + 00:00 app [ web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:124:in`block in constantize'
3:15 + 00:00应用[web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:123:in从/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/inflector/methods获得`each'
3:15 + 00:00 a
。 rb:123:在`constantize'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib /active_support/core_ext/string/inflections.rb:43:in`constantize'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/ gems / activesupport-3.1.1 / lib / active_support / dependencies.rb:348:在`require_or_l oad'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb :181:在`block in const_missing'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/ lib / action_controller / metal / params_wrapper.rb:148:在`_default_wrap_model'
3:15 + 00:00 app [web.1]中:from /app/.bundle/gems/ruby/1.9.1/gems /actionpack-3.1.1/lib/action_controller/metal/params_wrapper.rb:167:in`_set_wrapper_defaults'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ ruby / 1.9.1 / gems / actionpack-3.1.1 / lib / action_controller / metal / params_wrapper.rb:128:在`继承'
3:15 + 00:00 app [web.1]:from / app / .bundle / gems / ruby​​ / 1.9.1 / gems / actionpack-3.1.1 / lib / abstract_controller / railties / routes_helpers.rb:7:在wi
$ b $的`block(2 levels) 3:15 + 00:00应用[web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/railties/paths.rb:7:in `块(2级)与'
3:15 + 00:00应用程序[我们b.1]:from /app/app/controllers/users_controller.rb:1:in`< top(required)>'
3:15 + 00:00 app [web.1]:from / app / .bundle / gems / ruby​​ / 1.9.1 / gems / activesupport-3.1.1 / lib / active_support / dependencies.rb:240:在`block in require'
3:15 + 00:00 app [ web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:225:in`load_dependency'
3:15+ 00:00 app [web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in`require'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in`需要'
3:15 + 00:00应用[web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb :348:在'require_or_load'
3:15 + 00:00 app [web.1]中:from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/ active_support / dependencies.rb:302:在`depend_on'
3:15 + 00:00 app [web.1]中: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:214:in' require_dependency'
3:15 + 00:00 app [ web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:417:in'block(2 levels)in eager_load!'
3:15 + 00:00应用[web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:416:在'each'
3:15 + 00:00 app [web.1]中:from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine .rb:416:在`block in eager_load!'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1 .1 / lib / rails / engine.rb:414:在`each'
3:15 + 00:00 app [web.1]中:from /app/.bundle/gems/ruby/1.9.1/ gems / railties-3.1.1 / lib / rails / engine.rb:414:在`eager_load!'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ ruby / 1.9.1 / gems / railties-3.1.1 / lib / rails / application / finisher.rb:51:在< module:Finisher>块中
3:15 + 00:00 app [ web.1]:从/app/.bundle/gems/ruby/1.9.1/ gems / railties-3.1.1 / lib / rails / initializable.rb:30:在`instance_exec'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby /1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:30:in`run'
3:15 + 00:00 app [web.1]:from / app /。 bundle / gems / ruby​​ / 1.9.1 / gems / railties-3.1.1 / lib / rails / initializable.rb:55:在`block in run_initializers'
3:15 + 00:00 app [web.1 ]:from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:54:in`each'
3:15 + 00:00 app [web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:54:in`run_initializers'
3: 15 + 00:00应用[web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/application.rb:96:in`initialize!'
3:15 + 00:00 app [web.1]:from /app/config/environment.rb:5:in`< top(required)>'
3:15 + 00 :00 app [web.1]:从< internal:lib / ruby​​gems / custom_require>:29:在'require'
3:15 + 00:00 app [web.1]:from< internal: LIB /的rubygems / custom_re quire>:29:在'require'
3:15 + 00:00 app [web.1]:from config.ru:3:in`block(3 levels)in< main>'
3:15 + 00:00 app [web.1]:from /home/heroku_rack/heroku.ru:23:in`eval'
3:15 + 00:00 app [web.1]:from /home/heroku_rack/heroku.ru:23:in`在< main>'
3:15 + 00:00应用程序[web.1]中拦截(3个级别):from /app/.bundle/gems /ruby/1.9.1/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in' method_missing'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:120:in`new'
3:15 + 00:00 app [web .1]:从/app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:120:在`map'
3:15 + 00 :00 app [web.1]:from /home/heroku_rack/heroku.ru:18:in`block(2 levels)in< main>'
3:15 + 00:00 app [web.1 ]:from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in`instance_eval'
3:15 + 00:00 app [web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.r b:51:在`initialize'
3:15 + 00:00 app [web.1]:from /home/heroku_rack/heroku.ru:11:in`new'
3:15+ 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in`instance_eval'
3:15 + 00:00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in`初始化'
3:15 + 00:00 app [web.1]:from /home/heroku_rack/heroku.ru:11:in`block in< main>'
3:15 + 00 :00 app [web.1]:from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in`instance_eval'
3:15 + 00:00应用[web.1]:从/app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in`initialize '
3:15 + 00:00 app [web.1]:from /home/heroku_rack/heroku.ru:1:in`new'
3:15 + 00:00 app [web。 1]:from /home/heroku_rack/heroku.ru:1:in`< main>'
3:15 + 00:00 app [web.1]:from /usr/ruby1.9.2/lib/ ruby / gems / 1.9.1 / gems / thin-1.2.6 / lib / rack / adapter / loader.rb:36:在`eval'
3:15 + 00:00 app [web.1] :from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in`load'
3:15 +00:00应用[web.1]:从/usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config'
3:15 + 00:00 app [web.1]:from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin /controllers/controller.rb:65:in`start'
3:15 + 00:00 app [web.1]:from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems /thin-1.2.6/lib/thin/runner.rb:143:in`run!'
3:15 + 00:00 app [web.1]:from /usr/ruby1.9.2/lib/ ruby / gems / 1.9.1 / gems / thin-1.2.6 / bin / thin:6:在<< top(required)>'
3:15 + 00:00 app [web.1] :from /usr/ruby1.9.2/bin/thin:19:in`load'
3:15 + 00:00 app [web.1]:from /usr/ruby1.9.2/bin/thin:19 :在< main>'
3:15 + 00:00 app [web.1]中:from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2。 6 / lib / thin / runner.rb:177:在`run_command'
3:16 + 00:00 heroku [web.1]:状态从开始变为崩溃
3:1 7 + 00:00 heroku [web.1]:进程退出
5:55 + 00:00 heroku [router]:错误H10(应用程序崩溃) - > GET highwind-7473.heroku.com/pages/home dyno = queue = wait = service = status = 503 bytes =
5:57 + 00:00 heroku [router]:Error H10(App crashed) - > GET highwind-7473.heroku.com/pages/home dyno = queue = wait = service = status = 503 bytes =



卡住的类型,请帮助(指向正确方向)

当然

  bundle install 
git add。
git commit -m另一个heroku修复程序
git push
git push heroku


DATABASE_URL 环境变量和您的在线Postgres数据库的路径。



尝试运行 heroku pg 。如果输出是myapp没有heroku-postgresql数据库。那么您需要首先添加PostgreSQL插件。它会在Amazon AWS上为您创建一个postgres数据库。

  heroku addons:add heroku-postgresql:hobby-basic 

(爱好 - 基本是免费计划)

要找到新数据库的URL,请运行

  heroku config 

您应该看到一个以 HEROKU_POSTGRESQL 开头的变量。复制它的值(它应该以 postgres:// 开头并用它来设置 DATABASE_URL

  heroku config:set DATABASE_URL = postgres:// your-db-url 


EDIT: The general advice is to use CEDAR stack.

Pretty new to RoR, Gems, Heroku and Git. Following tutorial: http://ruby.railstutorial.org/book/ruby-on-rails-tutorial

Works smoothly on localhost, when deployed to Heroku got ConnectionNotEstablished error, that was solved here: https://stackoverflow.com/questions/7542745/heroku-error-activerecordconnectionnotestablished (BTW: following same tutorial) After changing production database to PostgreSQL (gem 'pg') it generates another error:

Visting live site

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

Tried this - Heroku app crashed, receiving "Invalid DATABASE URL" when attempting heroku rake db:migrate - heroku rake db:migrate

rake aborted!
Invalid DATABASE_URL

Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)

heroku console

Internal server error

gemfile

source 'http://rubygems.org'

gem 'rails', '3.1.1'

group :development do
  gem 'rspec-rails', '2.6.1'
  gem 'annotate', '~> 2.4.1.beta' 
  gem 'sqlite3'
end

group :test do
  gem 'rspec-rails', '2.6.1'
  gem 'webrat', '0.7.1'
  gem 'sqlite3'
end

group :production do
    gem 'pg'
end

group :assets do
  gem 'sass-rails',   '~> 3.1.4'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

heroku logs

9:02+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in `run!'
9:02+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>'
9:02+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
9:02+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>'
9:02+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize'
9:02+00:00 app[web.1]:   from /usr/ruby1.9.2/bin/thin:19:in `<main>'
9:02+00:00 app[web.1]:   from /usr/ruby1.9.2/bin/thin:19:in `load'
9:03+00:00 heroku[web.1]: State changed from starting to crashed
9:04+00:00 heroku[web.1]: Process exited
1:58+00:00 heroku[slugc]: Slug compilation started
3:09+00:00 heroku[api]: Deploy 3dea426 by mstefanow@gmail.com
3:09+00:00 heroku[api]: Release v7 created by mstefanow@gmail.com
3:09+00:00 heroku[web.1]: State changed from crashed to created
3:09+00:00 heroku[web.1]: State changed from created to starting
3:10+00:00 heroku[slugc]: Slug compilation finished
3:12+00:00 heroku[web.1]: Starting process with command `thin -p 44881 -e production -R /home/heroku_rack/heroku.ru start`
3:15+00:00 app[web.1]: (erb):9:in `rescue in <main>': Invalid DATABASE_URL (RuntimeError)
3:15+00:00 app[web.1]:   from (erb):6:in `<main>'
3:15+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `eval'
3:15+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `result'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/application/configuration.rb:106:in `database_configuration'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/railtie.rb:68:in `block (2 levels) in <class:Railtie>'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in `each'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/base.rb:2190:in `<top (required)>'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:225:in `load_dependency'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:489:in `load_missing_constant'
3:15+00:00 app[web.1]:   from /app/app/models/user.rb:12:in `<top (required)>'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:179:in `each'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:179:in `const_missing'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:124:in `block in constantize'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:123:in `each'
3:15+00:00 a
 from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:123:in `constantize'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:348:in `require_or_load'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:181:in `block in const_missing'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/params_wrapper.rb:148:in `_default_wrap_model'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/params_wrapper.rb:167:in `_set_wrapper_defaults'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/params_wrapper.rb:128:in `inherited'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/lib/abstract_controller/railties/routes_helpers.rb:7:in `block (2 levels) in wi

3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/railties/paths.rb:7:in `block (2 levels) in with'
3:15+00:00 app[web.1]:   from /app/app/controllers/users_controller.rb:1:in `<top (required)>'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:225:in `load_dependency'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:348:in `require_or_load'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:302:in `depend_on'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:214:in `require_dependency'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:417:in `block (2 levels) in eager_load!'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:416:in `each'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:416:in `block in eager_load!'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:414:in `each'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:414:in `eager_load!'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/application/finisher.rb:51:in `block in <module:Finisher>'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
3:15+00:00 app[web.1]:   from /app/config/environment.rb:5:in `<top (required)>'
3:15+00:00 app[web.1]:   from <internal:lib/rubygems/custom_require>:29:in `require'
3:15+00:00 app[web.1]:   from <internal:lib/rubygems/custom_require>:29:in `require'
3:15+00:00 app[web.1]:   from config.ru:3:in `block (3 levels) in <main>'
3:15+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:23:in `eval'
3:15+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:23:in `block (3 levels) in <main>'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:120:in `new'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:120:in `map'
3:15+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `instance_eval'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize'
3:15+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:11:in `new'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `instance_eval'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize'
3:15+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:11:in `block in <main>'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `instance_eval'
3:15+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize'
3:15+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:1:in `new'
3:15+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:1:in `<main>'
3:15+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval'
3:15+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load'
3:15+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config'
3:15+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start'
3:15+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in `run!'
3:15+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>'
3:15+00:00 app[web.1]:   from /usr/ruby1.9.2/bin/thin:19:in `load'
3:15+00:00 app[web.1]:   from /usr/ruby1.9.2/bin/thin:19:in `<main>'
3:15+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
3:16+00:00 heroku[web.1]: State changed from starting to crashed
3:17+00:00 heroku[web.1]: Process exited
5:55+00:00 heroku[router]: Error H10 (App crashed) -> GET high-wind-7473.heroku.com/pages/home dyno= queue= wait= service= status=503 bytes=
5:57+00:00 heroku[router]: Error H10 (App crashed) -> GET high-wind-7473.heroku.com/pages/home dyno= queue= wait= service= status=503 bytes=

Kind of stuck, please help (point in right direction)

Of course

bundle install
git add .
git commit -m "another heroku fix"
git push
git push heroku

解决方案

You need to set the DATABASE_URL environment variable with the path to your online postgres db.

Try running heroku pg. If the output is "myapp has no heroku-postgresql databases." then you need to add the PostgreSQL add-on first. It will create a postgres db for you on Amazon AWS.

heroku addons:add heroku-postgresql:hobby-basic

(hobby-basic is the free plan)

To find the URL for your new database, run

heroku config

You should see a variable that starts with HEROKU_POSTGRESQL. Copy its value (it should start with postgres:// and use it to set the DATABASE_URL

heroku config:set DATABASE_URL=postgres://your-db-url

这篇关于Heroku on Rails - 无效的DATABASE_URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆