Skip to content

Instantly share code, notes, and snippets.

@duncanbeevers
Forked from rubytastic/gist:1798913
Created February 11, 2012 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duncanbeevers/1798922 to your computer and use it in GitHub Desktop.
Save duncanbeevers/1798922 to your computer and use it in GitHub Desktop.
namespace :db do
desc "Populate Users Table with images from /public/feedimg"
task :populate => :environment do
require "populator"
require "faker"
image_filenames = Dir.glob(File.join(Rails.root, '/public/feedimg', '*'))
User.populate 1 do |user|
user.username = Faker::Name.first_name.downcase
user.email = Faker::Internet.user_name + "@myhost.com".downcase
user.confirmed_at = DateTime.now
user.created_at = DateTime.now
end
User.all.each do |user|
File.open(image_filenames.sample, "r") do |file|
user.create_attachable(file: file)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment