Example of creating seed data with seed-fu

Posted . Visible to the public.

Using an existing table to programmatically create initial seed fu data definition

locations = CountryLocation.all
SeedFu::Writer.write("db/fixtures/country_locations.rb", class_name: "CountryLocation", :constraints => [:id]) do |writer|
  locations.each do |l|
    writer.add(id: l.id, iso: l.iso, name: l.name, printable_name: l.printable_name, iso3: l.iso3, numcode: l.numcode, email: l.email)
  end
end
Andy Henson
Last edit
Andy Henson
Posted by Andy Henson to Foxsoft (2017-03-29 12:00)