# Rake task to populate a table

**URL:** <https://www.ruby-forum.com/t/rake-task-to-populate-a-table/128280>\
**Category:** Rails\
**Created:** [February 6, 2008, 11:45am UTC](https://www.ruby-forum.com/t/rake-task-to-populate-a-table/128280 "2008-02-06T11:45:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [February 6, 2008, 11:45am UTC](https://www.ruby-forum.com/t/rake-task-to-populate-a-table/128280/1 "2008-02-06T11:45:32Z")

</div>

It seems that it’s possible to create a rake task to populate db tables,  
this is what I want to accomplish and rake seems like the best tool.  
However, the only examples I found are rather complex.

How can I get started on this, please?

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [February 8, 2008, 12:08am UTC](https://www.ruby-forum.com/t/rake-task-to-populate-a-table/128280/2 "2008-02-08T00:08:21Z")

</div>

Mephisto’s bootstrap task is what I looked at initially and based my  
Kete  
app’s bootstrap task on:  
[http://development.kete.net.nz/kete/repository/file/trunk/lib/tasks/bootstrap.rake](http://development.kete.net.nz/kete/repository/file/trunk/lib/tasks/bootstrap.rake)

That simply uses fixtures. If you want to get a little more hands on  
(and  
not delete existing data in the table), you can deal with your Rails  
models  
directly from rake. Examples can be found in here:

[http://development.kete.net.nz/kete/repository/file/trunk/lib/tasks/upgrade.rake](http://development.kete.net.nz/kete/repository/file/trunk/lib/tasks/upgrade.rake)

Cheers,  
Walter
