Created
July 22, 2019 18:13
-
-
Save HenryTabima/2de5826c94f611192f7955034939c878 to your computer and use it in GitHub Desktop.
Imagining that I have the models User and Post where users have many posts
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 characters
| # Imagine I have the models User and Post where users have many posts | |
| if Rails.env.development? || Rails.env.test? | |
| namespace :dev do | |
| desc 'This will add some development data ' | |
| task populate: 'db:migrate:reset' do | |
| 3.times do |i| | |
| user = User.create(…) #imagine the user content instead of "…" | |
| user.posts.create(…) #imagine post content instead of "…" | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment