Skip to content

Instantly share code, notes, and snippets.

@taiansu
Created December 9, 2012 18:20
Show Gist options
  • Save taiansu/4246354 to your computer and use it in GitHub Desktop.
Save taiansu/4246354 to your computer and use it in GitHub Desktop.
in lib/tasks
namespace :db do
desc "Erase and fill database"
task :populate => :environment do
require 'populator'
#require 'faker'
[Category, Record].each(&:delete_all)
Category.populate 10 do |category|
category.title = Populator.words(2)
Record.populate 500..1000 do |record|
record.title = Populator.words(3)
record.amount = 10..10000
record.category_id = category.id
record.date = Date.new(2012,2,3)...Date.new(2012,12,30)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment