2017-06-12 101 views
0

不解析数据库URL我有以下database.yml文件:Rails的生产

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'] %> 

和我有类似postgresql://user:[email protected]/backoffice_api

对生产DATABASE_URL当我尝试开始生产,我得到我的应用程序这个错误:

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:[email protected]/backoffice_api' 

和其他一些例外线后:

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' 

我显然不使用MySQL,如果在我的机器上使用该URL,它的工作原理!有什么可能是错的?

回答

1

尝试

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