Skip to content

Instantly share code, notes, and snippets.

@pullmonkey
Created August 11, 2012 01:04
Show Gist options
  • Save pullmonkey/3319679 to your computer and use it in GitHub Desktop.
Save pullmonkey/3319679 to your computer and use it in GitHub Desktop.
dynamic select seed
3.times do |x|
genre = Genre.find_or_create_by_name(:name => "Genre #{x}")
3.times do |y|
artist = Artist.find_or_create_by_name(:name => "Artist #{x}.#{y}", :genre => genre)
3.times do |z|
Song.find_or_create_by_title(:title => "Song #{x}.#{y}.#{z}", :artist => artist)
end
end
end
@rajeevkannav
Copy link

should be :

3.times do |x|
genre = Genre.find_or_create_by_name(:name => "Genre #{x}")
3.times do |y|
artist = Artist.find_or_create_by_name(:name => "Artist #{x}.#{y}", :genre_id => genre.id)
3.times do |z|
Song.find_or_create_by_title(:title => "Song #{x}.#{y}.#{z}", :artist_id => artist.id)
end
end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment