Last active
December 8, 2020 15:45
-
-
Save raghubetina/9b1dd3f6fcb0a459b6244c379628c675 to your computer and use it in GitHub Desktop.
Revisions
-
raghubetina revised this gist
May 16, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,10 +29,10 @@ bundle install Then run the following command: ```bash rake db:seed:dump EXCLUDE=[] ``` This will replace your existing `db/seeds.rb` file (say "yes" if it asks your permission to overwrite). (You could also choose to exclude certain columns.) You can now `rake db:seed` whenever you want to re-create your data; for example, if things get into a bad state, you can -
raghubetina revised this gist
May 16, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -50,4 +50,4 @@ The other way to go is to write some plain old Ruby yourself to do the work of C ## From a CSV [Here is a guide to seeding from a CSV file.](https://guides.firstdraft.com/loading-data-from-a-csv-file-into-your-database.html) -
raghubetina revised this gist
Jun 23, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ bundle install Then run the following command: ```bash rake db:seed:dump EXCLUDE= ``` This will replace your existing `db/seeds.rb` file (say "yes" if it asks your permission to overwrite). -
raghubetina revised this gist
Jun 3, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -50,4 +50,4 @@ The other way to go is to write some plain old Ruby yourself to do the work of C ## From a CSV [Here is a guide to seeding from a CSV file.](https://gist.github.com/arjunvenkat/1115bc41bf395a162084) -
raghubetina revised this gist
Jun 3, 2016 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -48,3 +48,6 @@ to reset. You can re-run `rake db:seed:dump EXCLUDE=[]` at any time to overwrite The other way to go is to write some plain old Ruby yourself to do the work of CRUDing some starter data. I often use the [faker gem](https://github.com/stympy/faker) to help with this; [here is an example](https://github.com/firstdraft/listception_auth/blob/master/db/seeds.rb). ## From a CSV [Follow Arjun's guide to seeding from a CSV file.](https://gist.github.com/arjunvenkat/1115bc41bf395a162084) -
raghubetina revised this gist
Jun 3, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,7 +42,7 @@ rake db:migrate rake db:seed ``` to reset. You can re-run `rake db:seed:dump EXCLUDE=[]` at any time to overwrite your `db/seeds.rb` again with the current state of your tables. ## Write some Ruby yourself -
raghubetina revised this gist
Jun 3, 2016 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,3 +43,8 @@ rake db:seed ``` to reset. ## Write some Ruby yourself The other way to go is to write some plain old Ruby yourself to do the work of CRUDing some starter data. I often use the [faker gem](https://github.com/stympy/faker) to help with this; [here is an example](https://github.com/firstdraft/listception_auth/blob/master/db/seeds.rb). -
raghubetina created this gist
Jun 3, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ # Seeding your database It is very helpful to take the time to pre-populate your database with some dummy data before you start working on any features. It's nice to have some data to look at to see whether you are going down the right path. It's also very helpful to other developers on the project, so they can get started quickly right after they clone. Here are two ways to create seed data: ## Manually + `seed_dump` The simplest way is to use the forms that were written by the generator, and manually enter some realistic data. (It might help to at least replace the `<input type="text" ...>`s for foreign keys with `<%= select_tag ... %>`s before doing this, to make your life a little easier.) Once you've added some data to your tables manually, we can use the [seed_dump gem](https://github.com/rroblak/seed_dump) to automatically generate a `db/seeds.rb` file for us: Add the gem: ```ruby # Gemfile gem "seed_dump" ``` ```bash bundle install ``` Then run the following command: ```bash rake db:seed:dump EXCLUDE=[] ``` This will replace your existing `db/seeds.rb` file (say "yes" if it asks your permission to overwrite). You can now `rake db:seed` whenever you want to re-create your data; for example, if things get into a bad state, you can ```bash rake db:drop rake db:migrate rake db:seed ``` to reset.