Skip to content

Instantly share code, notes, and snippets.

@HenryTabima
Created July 22, 2019 18:13
Show Gist options
  • Select an option

  • Save HenryTabima/2de5826c94f611192f7955034939c878 to your computer and use it in GitHub Desktop.

Select an option

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
# 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