Incomplete Seeding

Fixed the seeding bugs with much help from Michael.
I might just do that. I will mention, though, that the reason it had to be
assigned to a variable was that the randomization method was running each
time a new user's address was added.

On Fri, Oct 3, 2014 at 2:35 PM, Michael Alexander <notifications@github.com>
wrote:

> In db/seeds.rb:
>
> > +      end
> > +    end
> > +  end
> > +  [cities, towns, villages]
> > +end
> > +
> > +SAMPLECITIES = sample_cities
> > +
> > +def random_user_addresses(user_id)
> > +  address_choices = (Address.select(:id).where(:user_id => user_id)).to_a
> > +  address_choices[0] ? [address_choices.sample[:id], address_choices.sample[:id]] : [nil, nil]
> > +end
> > +
> > +def generate_addresses(user_id)
> > +  (rand(6)).times do
> > +    city_instance = SAMPLECITIES.sample.sample
>
> We are *almost* getting into @Board.board.board territory here, but I'll
> let it go. I think if you're going to abstract this kind of thing, you
> should write another method to interface with a SAMPLE_CITIES array and
> return a single city, thus making it much more portable.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/vikingeducation/viking_store/pull/2/files#r18420902>.
>