Skip to content

Commit

Permalink
Added rake task - bootstrap - to populate database
Browse files Browse the repository at this point in the history
  • Loading branch information
arafatm committed Nov 12, 2008
1 parent fb59fe7 commit f35693e
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions lib/tasks/bootstrap.rake
@@ -1,11 +1,36 @@
namespace :bootstrap do
desc "Add the default user"
task :user => :environment do
User.create(:name => 'user',
:login => 'user',
:password => 'user99',
:password_confirmation => 'user99',
:email => 'user@capwn.com',
:admin => true)
end
task :bootstrap => :environment do

# Create User
u = User.generate(:name => 'user',
:login => 'user',
:password => 'user99',
:password_confirmation => 'user99',
:email => 'user@capwn.com',
:admin => true)

# Create Accounts
income = Account.generate(:name => 'Income')
checking = Account.generate(:name => 'Checking')
taxes = Account.generate(:name => 'Taxes')
groceries = Account.generate(:name => 'Groceries')

# Create Transactions/Entries
t1 = Transaction.generate(:memo => 'Paycheck',
:user => u)

t1e1 = Entry.generate(:amount => 80,
:debit_account => income,
:credit_account => checking,
:transaction => t1)
t1e2 = Entry.generate(:amount => 20,
:debit_account => income,
:credit_account => taxes,
:transaction => t1)

t2 = Transaction.generate(:memo => 'Buy Groceries',
:user => u)

t2e1 = Entry.generate(:debit_account => checking,
:credit_account => groceries,
:transaction => t2)
end

0 comments on commit f35693e

Please sign in to comment.