Rails无法在生产中解析数据库URL

编程入门 行业动态 更新时间:2024-10-23 01:33:41
本文介绍了Rails无法在生产中解析数据库URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下database.yml文件:

I have the following database.yml file:

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

,我在生产中有一个DATABASE_URL,类似于 postgresql:// user: passwrd@backoffice.xxxxxxxx.xxxxx.rds.amazonaws/backoffice_api

and I have a DATABASE_URL on production similar to postgresql://user:passwrd@backoffice.xxxxxxxx.xxxxx.rds.amazonaws/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/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'

我显然不是在使用MySQL,如果在我的机器上使用该URL,它将起作用!

I'm obviously not using MySQL and if use that URL on my machine, it works! what could be wrong?

推荐答案

尝试

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

更多推荐

Rails无法在生产中解析数据库URL

本文发布于:2023-11-16 07:39:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1602307.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   Rails   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!