jatwell93 / rubyproject

1 stars 1 forks source link

Seeding data #9

Closed Mirv closed 7 years ago

Mirv commented 7 years ago

I put a basic file in /db/seed.rb for now, it sets up a user/pass & then creates a few recipes with their nested attributes.

To run it ...

First, delete all those migrations - it's a timesink to trouble shoot them. Then...

rake db:reset

Which will unload the database, clearing everything out - then insert the data as fresh.

Optionally, you can ....

rake db:seed

Which will stack the old entries on top of the new - but you're going to get a validation issue in there too as it stands - which is why I've got this ticket open.

I need to put in a rescue in case of validation failing so the seeding process just keeps plugging along, instead of failing & cancelling all entries.

jatwell93 commented 7 years ago

Thanks for that i've been meaning to make a seeds file. When you say "delete all those migrations" is that in reference to all the files in the db>migrate folder?

Mirv commented 7 years ago

Np.

Yes - I'm always fighting the migrations, if you have them archived already you can go back to them - keep committing your migrations and then delete them on the next?

I was going to add faker gem to generate random names - with your permission I'll go ahead and stick that in there at some point?