Skip to content

Commit

Permalink
Add Faker Gem
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcockerham committed Jul 4, 2013
1 parent 754525d commit baa5dda
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ doc/
.idea

# Ignore Paperclip uploaded files
/public/system
/public/system

# Ignore sample images
/sampleimages
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gem 'devise'
gem 'simple_form'
gem "paperclip", "~> 3.0"
gem 'aws-sdk'
gem 'faker'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ GEM
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
faker (1.1.2)
i18n (~> 0.5)
hike (1.2.2)
i18n (0.6.4)
journey (1.0.4)
Expand Down Expand Up @@ -139,6 +141,7 @@ DEPENDENCIES
bootstrap-sass (~> 2.3.1.0)
coffee-rails (~> 3.2.1)
devise
faker
jquery-rails
paperclip (~> 3.0)
pg
Expand Down
24 changes: 24 additions & 0 deletions lib/tasks/populate.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace :db do
desc "Fill database with sample data"
task populate: :environment do
10.times do |n|
puts "[DEBUG] creating user fake #{n+20} of 10"
name = Faker::Name.name
email = "fake-#{n+20}@example.com"
password = "password"
User.create!( name: name,
email: email,
password: password,
password_confirmation: password)
end

User.last(10).each do |user|
puts "[DEBUG] uploading images for user #{user.id} of #{User.last.id}"
10.times do |n|
image = File.open(Dir.glob(File.join(Rails.root, 'sampleimages', '*')).sample)
description = %w(cool awesome crazy wow adorbs incredible).sample
user.pins.create!(image: image, description: description)
end
end
end
end

0 comments on commit baa5dda

Please sign in to comment.