From fc355c5214ae883c3b827987084e374467d52c4f Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 18 Jan 2011 23:53:40 -0600 Subject: [PATCH] removed sample_data.rake --- lib/tasks/sample_data.rake | 45 -------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 lib/tasks/sample_data.rake diff --git a/lib/tasks/sample_data.rake b/lib/tasks/sample_data.rake deleted file mode 100644 index 6d77548..0000000 --- a/lib/tasks/sample_data.rake +++ /dev/null @@ -1,45 +0,0 @@ -require 'faker' - -namespace :db do - desc "Fill database with sample data" - task :populate => :environment do - Rake::Task['db:reset'].invoke - make_users - make_microposts - make_relationships - end -end - -def make_users - admin = User.create!(:name => "Example User", - :email => "example@railstutorial.org", - :password => "foobar", - :password_confirmation => "foobar") - admin.toggle!(:admin) - 99.times do |n| - name = Faker::Name.name - email = "example-#{n+1}@railstutorial.org" - password = "password" - User.create!(:name => name, - :email => email, - :password => password, - :password_confirmation => password) - end -end - -def make_microposts - User.all(:limit => 6).each do |user| - 50.times do - user.microposts.create!(:content => Faker::Lorem.sentence(5)) - end - end -end - -def make_relationships - users = User.all - user = users.first - following = users[1..50] - followers = users[3..40] - following.each { |followed| user.follow!(followed) } - followers.each { |follower| follower.follow!(user) } -end \ No newline at end of file