diff --git a/.gitignore b/.gitignore index e54dde9..d3d7cab 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,7 @@ doc/ .idea # Ignore Paperclip uploaded files -/public/system \ No newline at end of file +/public/system + +# Ignore sample images +/sampleimages \ No newline at end of file diff --git a/Gemfile b/Gemfile index 981d5f2..14293b1 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index f8df8b1..16d6967 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -139,6 +141,7 @@ DEPENDENCIES bootstrap-sass (~> 2.3.1.0) coffee-rails (~> 3.2.1) devise + faker jquery-rails paperclip (~> 3.0) pg diff --git a/lib/tasks/populate.rake b/lib/tasks/populate.rake new file mode 100644 index 0000000..14d4fed --- /dev/null +++ b/lib/tasks/populate.rake @@ -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 \ No newline at end of file