Help integrating this railsweenie code

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

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

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 [email protected] wrote:

 require 'active_record/fixtures'


Posted via http://www.ruby-forum.com/.


Ed Hickey
Developer
Litmus Media
816-533-0409
[email protected]
A Member of Think Partnership, Inc
www.ThinkPartnership.com
Amex ticker symbol: THK

Put it in lib/tasks/bootstrap.rake

Awesome, thank you both!

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