Skip to content

Commit

Permalink
add faker gem
Browse files Browse the repository at this point in the history
  • Loading branch information
rmi22186 committed Sep 17, 2013
1 parent c212a1b commit cf2a64b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ doc/

# ignore paperclip uploaded files
/public/system

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

group :production do
gem 'pg'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ GEM
warden (~> 1.2.3)
erubis (2.7.0)
execjs (2.0.1)
faker (1.2.0)
i18n (~> 0.5)
hike (1.2.3)
i18n (0.6.5)
journey (1.0.4)
Expand Down Expand Up @@ -141,6 +143,7 @@ DEPENDENCIES
bootstrap-sass (~> 2.2.2.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 #{n+1} of 10"
name = Faker::Name.name
email = "user-#{n+1}@example1.com"
password = "password"
User.create!( name: name,
email: email,
password: password,
password_confirmation: password)
end

User.all.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 adorable incredible).sample
user.pins.create!(image: image, description: description)
end
end
end
end

0 comments on commit cf2a64b

Please sign in to comment.