Created
August 23, 2011 14:55
-
-
Save jt/1165339 to your computer and use it in GitHub Desktop.
Rails populate script
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
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