# Help integrating this railsweenie code

**URL:** <https://www.ruby-forum.com/t/help-integrating-this-railsweenie-code/73147>\
**Category:** Rails\
**Created:** [October 22, 2006, 12:35am UTC](https://www.ruby-forum.com/t/help-integrating-this-railsweenie-code/73147 "2006-10-22T00:35:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [October 22, 2006, 12:35am UTC](https://www.ruby-forum.com/t/help-integrating-this-railsweenie-code/73147/1 "2006-10-22T00:35:41Z")

</div>

Hi, I found this code in a great tip on railsweenie, but as someone new  
to rails I don’t know how to integrate this into my project. Can you  
please help?

Thank you in advance

The code is:  
[http://rails.techno-weenie.net/tip/2006/6/8/bootstrapping\_your\_database](http://rails.techno-weenie.net/tip/2006/6/8/bootstrapping_your_database)

namespace :db do  
desc “Loads a schema.rb file into the database and then loads the  
initial database fixtures.”  
task :bootstrap =\> [‘db:schema:load’, ‘db:bootstrap:load’]

namespace :bootstrap do  
desc "Load initial database fixtures (in db/bootstrap/_.yml) into  
the current environment’s database. Load specific fixtures using  
FIXTURES=x,y"  
task :load =\> :environment do  
require ‘active\_record/fixtures’  
ActiveRecord::Base.establish\_connection(RAILS\_ENV.to\_sym)  
(ENV[‘FIXTURES’] ? ENV[‘FIXTURES’].split(/,/) :  
Dir.glob(File.join(RAILS\_ROOT, ‘db’, ‘bootstrap’, '_.{yml,csv}'))).each  
do |fixture\_file|  
Fixtures.create\_fixtures(‘db/bootstrap’,  
File.basename(fixture\_file, ‘.\*’))  
end  
end  
end  
end

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [October 22, 2006, 1:07am UTC](https://www.ruby-forum.com/t/help-integrating-this-railsweenie-code/73147/2 "2006-10-22T01:07:10Z")

</div>

looks like a Rake task. try putting it in your Rakefile (in your Rails  
app’s root dir) and then run  
rake db:bootstrap

On 10/21/06, Jon [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> require 'active_record/fixtures'
> 
> ```
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ed Hickey  
Developer  
Litmus Media  
816-533-0409  
removed\_email\_address@domain.invalid  
A Member of Think Partnership, Inc  
[www.ThinkPartnership.com](http://www.ThinkPartnership.com)  
Amex ticker symbol: THK

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [October 22, 2006, 1:11am UTC](https://www.ruby-forum.com/t/help-integrating-this-railsweenie-code/73147/3 "2006-10-22T01:11:11Z")

</div>

Put it in lib/tasks/bootstrap.rake

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [October 22, 2006, 1:17am UTC](https://www.ruby-forum.com/t/help-integrating-this-railsweenie-code/73147/4 "2006-10-22T01:17:02Z")

</div>

Awesome, thank you both!

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [October 25, 2006, 8:25am UTC](https://www.ruby-forum.com/t/help-integrating-this-railsweenie-code/73147/5 "2006-10-25T08:25:04Z")

</div>

rake aborted!  
stack level too deep  
(erb):7056

I think I over estimated the work load this script could handle, or  
maybe I should use something like FasterCSV?

The file Im ‘bootstrapping’ is a world location database, about 158MB  
and over 3 million lines. I think Im going to have to go back to an SQL  
insert file, it would have been nice to have this all done through rake  
though, Ill just have to use it for smaller data sets.

3009059 db/bootstrap/locations.csv
