不知道我做错了什么,我试着在我的 database.yml 中忽略生产部分,但这没有用,现在我有这个:
development:
...
test:
...
production:
database: myapp_production
pool: 5
我的宝石文件:
gem 'pg', :group => :production
gem 'mysql2', '>= 0.3.18', '< 0.5', :group => [:development, :test]
运行时出现此错误:
Running rake db:setup on ⬢ still-crag-69600... up, run.8579 (Free)
rake aborted!
ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: ["development", "test"]
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:246:in `resolve_symbol_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:227:in `resolve_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:141:in `resolve'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:55:in `establish_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:139:in `create_current'
您需要在生产中添加以下内容:
adapter: postgresql
url: <%= ENV['DATABASE_URL'] %>
确保您已经创建了一个postgresql 插件。DATABASE_URL
添加 heroku postgresql 插件时会自动设置环境变量。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句