【发布时间】:2014-04-10 04:22:27
【问题描述】:
所以我正在尝试按照 .yml 文件中的建议为我的 rails 生产环境数据库设置一个环境变量。在我的 .bash_profile 中,我像这样导出它:
export DATABASE_URL=mysql2://<username>:<password>@localhost/<database>
我访问我的网站并收到“ActiveRecord::AdapterNotSpecified”错误。
我唯一能想到的是我的密码以 @ 符号结尾,这会使 url 有 @@ 并混淆密码结束和主机开始的位置?
如果有帮助的话,这个应用程序也托管在 Hostmonster 上
数据库.yml:
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: <username>
password: <password>
database: <database>
development:
<<: *default
database: <database>
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: <database>
# Avoid production credentials in the repository,
# instead read the configuration from the environment.
#
# Example:
# mysql2://myuser:mypass@localhost/somedatabase
#
production:
url: <%= ENV["DATABASE_URL"] %>
【问题讨论】:
-
您的
config/database.yml文件是什么样的?
标签: ruby-on-rails ruby mysql2