Skip to content

Instantly share code, notes, and snippets.

@rubytastic
Created February 11, 2012 11:37
Show Gist options
  • Save rubytastic/1798913 to your computer and use it in GitHub Desktop.
Save rubytastic/1798913 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"
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
Asset.populate 1 do |asset|
asset.file = File.open(Dir.glob(File.join(Rails.root, '/public/feedimg', '*')).sample);
asset.attachable_id = user.id;
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment