I'm a newbie in ruby and ruby on rails and I just deployed a simple app to Heroku just for practice.It is a simple blog app that has just the basics (articles,comments, tags, login) It's connected to my github repo and at first it wasn't running (even if it was successfully deployed) so I run this:
heroku run rake db:migrate --app "my-app-name"
After that my app was running normally but the database seems empty (tables are in there but with no values) and does not show up the articles in my front page as it should be. I'm sure that I haven't understand the migration of db quite well but shouldn't the db has the same content when I deploy my application ?
I'm sure that I haven't understand the migration of db quite well but shouldn't the db has the same content when I deploy my application ?
No, data doesn't appear in your application unless you create it, and it's not really clear what data you expect to see. An empty database is exactly what you should see, after deploying to Heroku for the first time, and running rails db:migrate
.
Are you expecting the data you created in your local development environment to appear in your deployed application? That isn't how databases work, your local data is for development purposes and is not "shipped" with your code. The data you create while working against (for example) localhost:3000
is completely unrelated to your production environment or production data.
On the other hand, if there is seeded data you expect to appear, and you're creating it in db/seeds.rb
, then you need to run rails db:seed
.