#1 new
Michael Bleigh

Add 'seed_many' functionality

Reported by Michael Bleigh | April 24th, 2008 @ 10:24 AM

Seed many would seed a group of records using special _array commands. Syntax should be as follows:

User.seed_many(:login) do |u|
  u.login_array = %w(bob kevin frank)
  u.role = 'Administrator' # will be the same for all seeds
  u.first_name_array = %w(Bob Kevin Frank)
  u.last_name_array = %w(Bobson Kevinson Frankle)
end

Should also be able to specify what should happen if the arrays are of inconsistent length (but raise an exception by default):

# Uses the last item for all remaining seeds when index runs out
User.seed_many(:login, :overflow => :last) do |u|
  ...
end

# Loops back through the array again
User.seed_many(:login, :overflow => :loop) do |u|
  ...
end

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

An attempt to simplify the usage of seed data in Rails applications through a dead simple API.

People watching this ticket

Pages