is there a rails way?
my brute force thinking is just put a while loop and a case statement in
the index function like this
num = 0
typenum = 0
while num < 200
when typenum
case 1
@something = Model.new
@something.whatever = 3
...
@something.save
case 2
...
...
case 5
...
end
typenum++
num++
typenum = 0 if typenum > 5
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?hl=en
-~----------~----~----~----~------~----~------~--~---
On Mar 29, 8:53 am, mixplate <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> is there a rails way? > > my brute force thinking is just put a while loop and a case statement in > the index function like this > > num = 0 > typenum = 0 > > while num < 200 > > when typenum > case 1 > @something = Model.new > @something.whatever = 3 > ... > @something.save > case 2 > ... > ... > case 5 > ... > end > > typenum++ > num++ > typenum = 0 if typenum > 5 > end > > -- > Posted viahttp://www.ruby-forum.com/.You want 40 instances of 5 different types of objects, right? [Model1,Model2,Model3,Model4,Model5].each do |model| 0.upto(40) { model.create(:whatever => 3) } end Is this what you''re looking for? Jeff softiesonrails.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 -~----------~----~----~----~------~----~------~--~---
awesome! but some of my models have different attributes and also i would like to have somewhat different values for each of them. numbers i can do a random, but not sure about the strings and text... Jeff Cohen wrote:> On Mar 29, 8:53 am, mixplate <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> when typenum >> end >> >> typenum++ >> num++ >> typenum = 0 if typenum > 5 >> end >> >> -- >> Posted viahttp://www.ruby-forum.com/. > > You want 40 instances of 5 different types of objects, right? > > [Model1,Model2,Model3,Model4,Model5].each do |model| > 0.upto(40) { model.create(:whatever => 3) } > end > > Is this what you''re looking for? > > Jeff > softiesonrails.com-- 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 load your test fixtures into the db using rake db:fixtures:load. b mixplate wrote:> awesome! but some of my models have different attributes and also i > would like to have somewhat different values for each of them. numbers i > can do a random, but not sure about the strings and text... > > > > > > Jeff Cohen wrote: >> On Mar 29, 8:53 am, mixplate <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >>> when typenum >>> end >>> >>> typenum++ >>> num++ >>> typenum = 0 if typenum > 5 >>> end >>> >>> -- >>> Posted viahttp://www.ruby-forum.com/. >> You want 40 instances of 5 different types of objects, right? >> >> [Model1,Model2,Model3,Model4,Model5].each do |model| >> 0.upto(40) { model.create(:whatever => 3) } >> end >> >> Is this what you''re looking for? >> >> Jeff >> softiesonrails.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 -~----------~----~----~----~------~----~------~--~---