简体   繁体   English

Rails在生产时不解析数据库URL

[英]Rails not parsing database URL on production

I have the following database.yml file: 我有以下database.yml文件:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 4 } %>

development:
  <<: *default
  database: backoffice_authentication_development

test:
  <<: *default
  database: backoffice_authentication_test

production:
  <<: *default
  url: <%= ENV['DATABASE_URL'] %>

and I have a DATABASE_URL on production similar to postgresql://user:passwrd@backoffice.xxxxxxxx.xxxxx.rds.amazonaws.com/backoffice_api 我有一个类似于postgresql://user:passwrd@backoffice.xxxxxxxx.xxxxx.rds.amazonaws.com/backoffice_api生产DATABASE_URL postgresql://user:passwrd@backoffice.xxxxxxxx.xxxxx.rds.amazonaws.com/backoffice_api

when I try start my app on production I get this error: 当我尝试在生产中启动我的应用程序时,我收到此错误:

2017-06-12T08:23:37.054417906Z Initialising & migrating DB
2017-06-12T08:23:38.381585952Z rake aborted!
2017-06-12T08:23:38.381700163Z URI::InvalidURIError: bad URI(is not URI?): 'postgresql://user:passwrd@backoffice.xxxxxxxx.xxxxx.rds.amazonaws.com/backoffice_api'

and after some other exception lines: 并在其他一些例外行之后:

2017-06-12T08:23:38.382052715Z /usr/local/bundle/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
2017-06-12T08:23:38.382055762Z /usr/local/bundle/gems/activerecord-5.0.2/lib/active_record/tasks/mysql_database_tasks.rb:6:in `<class:MySQLDatabaseTasks>'
2017-06-12T08:23:38.382058788Z /usr/local/bundle/gems/activerecord-5.0.2/lib/active_record/tasks/mysql_database_tasks.rb:3:in `<module:Tasks>'
2017-06-12T08:23:38.382061748Z /usr/local/bundle/gems/activerecord-5.0.2/lib/active_record/tasks/mysql_database_tasks.rb:2:in `<module:ActiveRecord>'
2017-06-12T08:23:38.382064754Z /usr/local/bundle/gems/activerecord-5.0.2/lib/active_record/tasks/mysql_database_tasks.rb:1:in `<top (required)>'
2017-06-12T08:23:38.382067605Z /usr/local/bundle/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
2017-06-12T08:23:38.382070389Z /usr/local/bundle/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `block in require'
2017-06-12T08:23:38.382073112Z /usr/local/bundle/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency'

I'm obviously not using MySQL and if use that URL on my machine, it works! 我显然不使用MySQL,如果在我的机器上使用该URL,它就可以了! what could be wrong? 什么可能是错的?

尝试

url: <%= URI.encode(ENV['DATABASE_URL'] )%>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM