基本 Rails 部署
我第一次尝试使用 Heroku 在 Rails 上部署我的应用程序。
我花了很多时间,但在某个地方还是有差距。
Git:创建私有仓库,已成功推送到git
Heroku:创建免费应用程序并成功推送(但应用程序“崩溃”)
本地:
rake db:schema:dump #success
rake db:schema:load RAILS_ENV=production #failure: production database is not configured
rake db:create db:load RAILS_ENV=production #failure: undefined method '[]' for nil:NilClass
active_record/railties/databases.rake:59:in 'rescue in create_database'
active_record/railties/databases.rake:39:in 'create_database'
我的database.yml文件:
defaults: &defaults
适配器:mysql
用户名:root
密码: 密码
主机:本地主机
开发:
<<:*默认值
数据库:project_dev
测试:
<<:*默认值
数据库:project_test
刚刚添加:
<代码>生产: <<:*默认值 数据库:project_product
我可能犯了一个完全菜鸟错误。你知道我哪里可能出错吗?
I am trying to deploy my app on Rails for the first time using Heroku.
I have spent quite a lot of time but there's a gap somewhere.
Git: created private repo, pushed to git successfully
Heroku: created free app and pushed successfully (but app 'crashes')
Local:
rake db:schema:dump #success
rake db:schema:load RAILS_ENV=production #failure: production database is not configured
rake db:create db:load RAILS_ENV=production #failure: undefined method '[]' for nil:NilClass
active_record/railties/databases.rake:59:in 'rescue in create_database'
active_record/railties/databases.rake:39:in 'create_database'
My database.yml file:
defaults: &defaults
adapter: mysql
username: root
password: password
host: localhost
development:
<<: *defaults
database: project_dev
test:
<<: *defaults
database: project_test
Just added:production:
<<: *defaults
database: project_production
I may be making a total rookie mistake. Do you know where I might be going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用命令
heroku rake db:schema:load
,它只需在 Heroku 环境中执行命令rake db:schema:load
即可。您无需担心数据库环境,它们是由 Heroku 在编译 slug 时自动配置的。
Use the command
heroku rake db:schema:load
, which simply executes the commandrake db:schema:load
on Heroku's environment.You do not need to worry about the database environments are they are automatically configured by Heroku on the compilation of the slug.
您正在运行的 rake 命令在您的开发计算机上运行。如果你想在服务器上运行rake命令,请使用heroku命令(示例):
注意,如果你想推送数据,你就做错了。访问 heroku.com 并查看那里的文档。
The rake commands which you are running, run on your development machine. If you want to run rake commands on the server, use the heroku command (example):
Note, if you want to push data, you are doing it wrong. Go to heroku.com and look at the docs there.