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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > 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 > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ed Hickey Developer Litmus Media 816-533-0409 ehickey-A4HEbNdjHgMmlAP/+Wk3EA@public.gmane.org A Member of Think Partnership, Inc www.ThinkPartnership.com Amex ticker symbol: THK --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Put it in lib/tasks/bootstrap.rake On 22/10/06, Ed Hickey <bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > > 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 > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > Ed Hickey > > Developer > > Litmus Media > > 816-533-0409 > > ehickey-A4HEbNdjHgMmlAP/+Wk3EA@public.gmane.org > > A Member of Think Partnership, Inc > > www.ThinkPartnership.com > > Amex ticker symbol: THK > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Awesome, thank you both! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---