Incomplete Seeding

Fixed the seeding bugs with much help from Michael.
Oops, I forgot Rand didn't make a float.

On Fri, Oct 3, 2014 at 3:29 PM, Andur Carr <notifications@github.com> wrote:

> In db/seeds.rb:
>
> > +def creation_date
> > +
> > +end
> > +
> > +(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
>
> rand(5) produces a 0 in 20% of cases. This way, about 20% of orders will
> not be completed (they are carts). Unfortunately, I still have to add a
> conditional so that there cannot be multiple shopping carts.
> … <#148d822331c79834_>
> On Fri, Oct 3, 2014 at 2:46 PM, Michael Alexander <
> notifications@github.com> wrote: In db/seeds.rb: > +def creation_date > +
> > +end > + > +(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 so rand(5) > 0 is pretty much
> always true, unless you get a value so low it approximates to 0. Can you
> explain this? — Reply to this email directly or view it on GitHub <
> https://github.com/vikingeducation/viking_store/pull/2/files#r18421305>.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/vikingeducation/viking_store/pull/2/files#r18422877>.
>



-- 

*Michael Alexander*

(310) 429-8822

alexandermw@gmail.com