数据库配置未指定适配器(Sinatra+;Heroku+;Activerecord)
我(在Sinatra+ActiveRecord Heroku上)收到一个错误,数据库配置未指定适配器(Sinatra+;Heroku+;Activerecord),activerecord,heroku,sinatra,Activerecord,Heroku,Sinatra,我(在Sinatra+ActiveRecord Heroku上)收到一个错误,数据库配置没有指定适配器 从一些研究来看,这似乎是因为Heroku预计在装配过程中不会使用环境变量 我从列出数据库URL的db环境文件中删除了env vars,但仍然收到相同的错误 编辑:这在一天前db文件未更改的情况下也起作用,所以我不确定会出什么问题 2015-09-01T02:44:40.980448+00:00 app[web.1]: I, [2015-09-01T02:44:40.980313 #3] IN
数据库配置没有指定适配器
从一些研究来看,这似乎是因为Heroku预计在装配过程中不会使用环境变量
我从列出数据库URL的db环境文件中删除了env vars,但仍然收到相同的错误
编辑:这在一天前db文件未更改的情况下也起作用,所以我不确定会出什么问题
2015-09-01T02:44:40.980448+00:00 app[web.1]: I, [2015-09-01T02:44:40.980313 #3] INFO -- : Refreshing Gem list
2015-09-01T02:44:41.459544+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:171:in `spec': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
2015-09-01T02:44:41.459548+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:50:in `establish_connection'
2015-09-01T02:44:41.459550+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-activerecord-2.0.8/lib/sinatra/activerecord.rb:43:in `database='
2015-09-01T02:44:41.459552+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1216:in `set'
2015-09-01T02:44:41.459554+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-activerecord-2.0.8/lib/sinatra/activerecord.rb:35:in `database_file='
2015-09-01T02:44:41.459555+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1216:in `set'
2015-09-01T02:44:41.459556+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-activerecord-2.0.8/lib/sinatra/activerecord.rb:19:in `registered'
2015-09-01T02:44:41.459560+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1399:in `block in register'
2015-09-01T02:44:41.459562+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1397:in `each'
2015-09-01T02:44:41.459563+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1397:in `register'
2015-09-01T02:44:41.459565+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1977:in `register'
2015-09-01T02:44:41.459566+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:2038:in `register'
2015-09-01T02:44:41.459567+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-activerecord-2.0.8/lib/sinatra/activerecord.rb:54:in `<module:Sinatra>'
2015-09-01T02:44:41.459569+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sinatra-activerecord-2.0.8/lib/sinatra/activerecord.rb:10:in `<top (required)>'
2015-09-01T02:44:41.459571+00:00 app[web.1]: from /app/app.rb:2:in `require'
2015-09-01T02:44:41.459575+00:00 app[web.1]: from /app/app.rb:2:in `<top (required)>'
2015-09-01T02:44:41.459576+00:00 app[web.1]: from config.ru:2:in `require'
2015-09-01T02:44:41.459578+00:00 app[web.1]: from config.ru:2:in `block in <main>'
2015-09-01T02:44:41.459587+00:00 app[web.1]: from config.ru:1:in `<main>'
2015-09-01T02:44:41.459589+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.9.0/lib/unicorn.rb:48:in `eval'
2015-09-01T02:44:41.459590+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.9.0/lib/unicorn.rb:48:in `block in builder'
2015-09-01T02:44:41.459581+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
2015-09-01T02:44:41.459600+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
2015-09-01T02:44:41.459582+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
2015-09-01T02:44:41.459601+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
2015-09-01T02:44:41.459584+00:00 app[web.1]: from config.ru:1:in `new'
2015-09-01T02:44:41.459593+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:768:in `build_app!'
2015-09-01T02:44:41.459595+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:137:in `start'
2015-09-01T02:44:41.459598+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.9.0/bin/unicorn:126:in `<top (required)>'
2015-09-01T02:44:41.459592+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:768:in `call'
2015-09-01T02:44:42.358161+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-01T02:44:42.351187+00:00 heroku[web.1]: Process exited with status 1
这是database.yml文件:
development:
adapter: postgresql
database: development
username: <%= ENV['PG_USER'] %>
password: <%= ENV['PG_PASS'] %>
host: localhost
test:
adapter: postgresql
database: test
username: <%= ENV['PG_USER'] %>
password: <%= ENV['PG_PASS'] %>
host: localhost
开发:
适配器:postgresql
数据库:开发
用户名:
密码:
主机:本地主机
测试:
适配器:postgresql
数据库:测试
用户名:
密码:
主机:本地主机
编辑2:看起来伤害来自四次提交中的一次。下面我们来看看其中一个发生了什么变化:(编辑3:?)您不需要像这样进行URL解析。几年前,我修补了ActiveRecord
,默认使用ENV['DATABASE\u URL']
(如果可用)。因此,如果设置了它(如果您安装了Heroku postgresql
,它就在Heroku上),那么只需调用ActiveRecord即可。建立连接
,它就会工作:我今天遇到了同样的问题,并联系了Heroku支持部门寻求帮助
他们向我介绍了他们的Ruby构建包的最新变化,请参见:
我更新了database.yml文件以反映更改,并引用了用于生产的数据库URL,我的应用程序正在重新部署
production:
url: <%= ENV['DATABASE_URL'] %>
生产:
网址:
显示数据库配置?您可能希望在该文件中隐藏用户/密码/主机信息。为了更安全是的,搞定了。我们找到了上面链接的断开的提交。我们认为错误来自于在错误的rspec测试中使用保留字“include”(在文件的末尾)。昨天在部署了一个微小的代码更改后,我遇到了完全相同的问题。我使用heroku回滚重置为以前的版本。也许是Heroku的问题?我这次退回了--看起来不是问题。你知道还有什么会导致这个错误吗?很好。你是个圣人,多谢了!这相当具有破坏性,应该很容易更新Sinatra/ActiveRecord应用程序的ruby所有者。
production:
url: <%= ENV['DATABASE_URL'] %>