Mysql heroku给出了错误ActiveRecord::AdapterNotSpecified:';生产';数据库未配置。可用:[“开发”、“测试”]
mydatabase.ymlMysql heroku给出了错误ActiveRecord::AdapterNotSpecified:';生产';数据库未配置。可用:[“开发”、“测试”],mysql,ruby-on-rails,ruby,heroku,heroku-cli,Mysql,Ruby On Rails,Ruby,Heroku,Heroku Cli,mydatabase.yml development: adapter: mysql2 encoding: utf8 reconnect: false database: organic_tomatoes_development pool: 5 username: root password: password test: adapter: mysql2 encoding: utf8 reconnect: false database: organi
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: organic_tomatoes_development
pool: 5
username: root
password: password
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: organic_tomatoes_test
pool: 5
username: root
password: password
production::
adapter: mysql2
encoding: utf8
reconnect: false
database: organic_tomatoes_production
pool: 5
username: root
password: password
我在heroku上部署我的站点。
当我运行heroku时运行rake db:migrate
它给出了一个错误
ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: ["development", "test"]
如何解决此错误?在数据库中创建生产条目。yml
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: organic_tomatoes_development
pool: 5
username: root
password: password
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: organic_tomatoes_test
pool: 5
username: root
password: password
production::
adapter: mysql2
encoding: utf8
reconnect: false
database: organic_tomatoes_production
pool: 5
username: root
password: password
您可以试试吗?根据共享的描述,您只指定了开发和测试环境,还需要添加生产环境设置 除此之外,您还需要添加ClearDB作为一个附加组件来使用mysql数据库 单击“显示配置变量”并复制CLEARDB_数据库_URL值 mysql://xxxxx@xxxx.cleardb.net/xxxxx?重新连接=真 @符号之后的所有内容,直到/是DB_主机 之后/之前的一切?是数据库吗 //until:后面的字符串是DB_用户名 与@之间的字符串是DB_密码
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: organic_tomatoes_development
pool: 5
username: root
password: password
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: organic_tomatoes_test
pool: 5
username: root
password: password
production:
adapter: mysql2
encoding: utf8
username: xxxx
password: xxxx
database: ENV["CLEARDB_DATABASE_URL"]
pool: 5
今天早上我遇到了这个问题,解决方法是在运行命令之前设置
RAILS\u ENV
变量'
RAILS_ENV=development heroku local
可能是@KickButtowski的重复我尝试过,但解决方案不起作用