简体   繁体   English

如何将数据上传到Heroku? 滑轨4

[英]How to Upload data to Heroku ? Rails 4

My Rails app is about an Online Shopping site. My Rails应用程序与在线购物网站有关。 I'm trying Deploy it to Heroku. 我正在尝试将其部署到Heroku。 I've done push to heroku,and rake db:migrate. 我已经完成了推送到heroku的操作,并完成了db:migrate的操作。

But now in the My web,it doesn't have any Data. 但是现在在My Web中,它没有任何数据。

In the localhost:3000,I can show Products,Phones,Users,etc. 在localhost:3000中,我可以显示产品,电话,用户等。 But in my web: https://boiling-bayou-5793.herokuapp.com/welcome/home 但是在我的网站上: https : //boiling-bayou-5793.herokuapp.com/welcome/home

It doesn't show anything. 它什么也没显示。 So what should I do to upload data from my PC to my web 那么我该怎么做才能将数据从PC上载到Web

The data from your local development database is not automatically transferred to the production environment. 本地开发数据库中的数据不会自动传输到生产环境。 There is no rake task to do that. 没有耙子任务可以做到这一点。

You can use seed files and the rake db:seed task to get some initial data in your (production) database. 您可以使用种子文件rake db:seed任务在(生产)数据库中获取一些初始数据。

A more heroku-specific method could be just loading a database dump. 特定于heroku的方法可能只是加载数据库转储。 Assuming you're using Postgresql, n your local computer do 假设您使用的是Postgresql,则您的本地计算机

pg_dump -h localhost -U username -Fc dbname > db.dump

upload the file somewhere on the internet (like Amazon S3 so you can get a direct download link) and then on heroku run 将文件上传到Internet上的某个位置(例如Amazon S3,以便您可以获得直接下载链接),然后在heroku上运行

heroku pgbackups:restore SHARED_DATABASE http://www.example.com/db.dump

Remember to remove the db dump right away if it's any kind of sensitive data! 如果是任何敏感数据,请记住立即删除数据库转储!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM