Incomplete Seeding

Fixed the seeding bugs with much help from Michael.
I changed it to exactly that, then incorporated the seed multiplier into
the time frames so that there will be more time frames with a higher
multiplier.

On Fri, Oct 3, 2014 at 2:43 PM, Michael Alexander <notifications@github.com>
wrote:

> In db/seeds.rb:
>
> > +(20*SCALAR).times do |x|
> > +  sample_name = Faker::Name.name
> > +  address_samples = generate_addresses(x+1)
> > +
> > +  u = User.new({id: x+1, name: sample_name, email: Faker::Internet.email(sample_name), phone_number: Faker::PhoneNumber.phone_number, default_billing_address: address_samples[0], default_shipping_address: address_samples[1]})
> > +
> > +  u.save
> > +end
> > +
> > +#generate orders
> > +def completion(user)
> > +  user[:default_billing_address] && rand(5) > 0
> > +end
> > +
> > +def placement_date
> > +  rand([Time.now - 12.month, Time.now - 8.month, Time.now - 4.month].sample..Time.now)
>
> there's a whole lot of ideas all in this one-liner. I'd be interested in
> seeing a verbose version that's more readable:
> a line to define your array and sample from it, a line to explain/define
> the range you are putting that sample value into, and a line to then pick a
> random value from that range.
> time_frames = [Time.now - 12.month, Time.now - 8.month, Time.now - 4.month]
> date_range = (time_frames.sample .. Time.now)
> rand(date_range)
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/vikingeducation/viking_store/pull/2/files#r18421220>.
>