简体   繁体   中英

Why is my Ruby on Rails database not being loaded ?

I downloaded a project from Google Drive after my friend modified it.

But when I ran the server, it still used the old database which I already had.

So after many attempts to fixing it, I did

 rake db:reset 

And this deleted all the data from the database.

So because of this, I deleted the project from my computer and dowloaded a copy again from google drive.

But when I run the project, there is no data in the database.

How can fix this? Should I get a dump of the database as well from my friend and then replace my current database?

There's two parts to your application: The application code and the database. The database persists until it's explicitly deleted. The code and database data are only related by configuration, deleting one does not delete the other.

Running rake db:reset nukes out whatever data is in your database.

Normally you'll need to download both the code and a snapshot database (a "dump") if you're looking to work with actual data, otherwise you'll be stuck using whatever's defined in the seeds.rb file.

I think that you have two steps here:

1) First you should restore your db structure. You can do that running rake db:create db:migrate .

2) Second you want to restore the information that existed in the db before you delete it.You should running only rake db:seed to restore all data in seed.rb to db.

Tip: Use git to share projecet instead of Google Drive! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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