Skip to content

Instantly share code, notes, and snippets.

@jt
Created August 23, 2011 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jt/1165339 to your computer and use it in GitHub Desktop.
Save jt/1165339 to your computer and use it in GitHub Desktop.
Rails populate script
namespace :db do
desc 'Populate test data'
task :populate => ['db:reset'] do
populate 'users' do
['john', 'jane'].each do |name|
Fabricate(:user, email: name+'@example.com')
end
end
populate 'posts' do
3.times { Fabricate(:post) }
end
end
def populate(name, &block)
print "Populating #{name}... "
yield
puts 'done'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment