Is there a way of automatically initializing a database with sample data? I ask because fixtures seems to be geared towards the test database (different from the development version) and that too it loads one table at a time (maybe I could have calls to all the fixtures in one test file?). Is there a typical way the rest of you are initializing a database with data for usage? -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
check out seed_fu, http://intridea.com/2008/4/20/seed-fu-simple-seed-data-for-rails On Jun 23, 2008, at 12:45 PM, Ather Shiraz wrote:> > Is there a way of automatically initializing a database with sample > data? I ask because fixtures seems to be geared towards the test > database (different from the development version) and that too it > loads > one table at a time (maybe I could have calls to all the fixtures in > one > test file?). Is there a typical way the rest of you are > initializing a > database with data for usage? > -- > 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?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve also been on projects where migrations are used to seed the data. Best. Mike On Jun 23, 2008, at 12:45 PM, Ather Shiraz wrote:> > Is there a way of automatically initializing a database with sample > data? I ask because fixtures seems to be geared towards the test > database (different from the development version) and that too it > loads > one table at a time (maybe I could have calls to all the fixtures in > one > test file?). Is there a typical way the rest of you are > initializing a > database with data for usage? > -- > 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?hl=en -~----------~----~----~----~------~----~------~--~---
You can also create a controller with generator methods based upon your needs: def test_products quantity = params[:id].to_i quantity.times do |i| product = Product.new( :created_at => Date.today, :name => ''Acme yoyo'' :price => ''5.00'') product.save end render :text => "Generated #{quantity} products." end You can edit this as needed, then execute this via url passing the # of products you want. Michael Breen wrote:> I''ve also been on projects where migrations are used to seed the data. > > Best. > Mike > > On Jun 23, 2008, at 12:45 PM, Ather Shiraz wrote: > >> Is there a way of automatically initializing a database with sample >> data? I ask because fixtures seems to be geared towards the test >> database (different from the development version) and that too it >> loads >> one table at a time (maybe I could have calls to all the fixtures in >> one >> test file?). Is there a typical way the rest of you are >> initializing a >> database with data for usage? >> -- >> 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?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Breen wrote:> I''ve also been on projects where migrations are used to seed the data. > > Best. > MikeI have encountered some where the migration has "MODEL_NAME".create :FIELD=>VALUE ... it sounds good .. maybe I could try that ... it seems the easiest to do . However, I like the flexibility of fixtures and the controller approach. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 23, 2008, at 3:12 PM, MW Administrator wrote:> > You can also create a controller with generator methods based upon > your > needs:Just make sure you don''t deploy this controller to the production site. Best. Mike> > > def test_products > quantity = params[:id].to_i > quantity.times do |i| > product = Product.new( > :created_at => Date.today, > :name => ''Acme yoyo'' > :price => ''5.00'') > product.save > end > render :text => "Generated #{quantity} products." > end > > You can edit this as needed, then execute this via url passing the # > of > products you want. > > > > Michael Breen wrote: >> I''ve also been on projects where migrations are used to seed the >> data. >> >> Best. >> Mike >> >> On Jun 23, 2008, at 12:45 PM, Ather Shiraz wrote: >> >>> Is there a way of automatically initializing a database with sample >>> data? I ask because fixtures seems to be geared towards the test >>> database (different from the development version) and that too it >>> loads >>> one table at a time (maybe I could have calls to all the fixtures in >>> one >>> test file?). Is there a typical way the rest of you are >>> initializing a >>> database with data for usage? >>> -- >>> 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?hl=en -~----------~----~----~----~------~----~------~--~---