Created
December 9, 2012 18:20
-
-
Save taiansu/4246354 to your computer and use it in GitHub Desktop.
in lib/tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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