Help with loading data with sequential id

Hello,

I'm trying to load data into my mysql table using the following:

============ load_codes_data.rb ============ require 'active_record/fixtures' class LoadCodesData < ActiveRecord::Migration   def self.up     down     directory = File.join(File.dirname("MY_DIR_NAME"), "data")     Fixtures.create_fixtures(directory, "codes")   end

  def self.down     Code.delete_all   end end

I suppose you want use the omap YAML type. Read about it in http://api.rubyonrails.org/classes/Fixtures.html and in Ordered Mapping Language-Independent Type for YAML™ Version 1.1.

Regards.

Franco Catena.

Thanks for the pointer! I modified the codes.yml file to look like this (below) and now it inserts ordered list with sequential ids. I had to try it several times to get the spacing right.. I had two spaces (no tabs) in front of the key:value pair initially, but it needed four spaces instead.

=============== codes.yml =================== --- !omap - r1:     id: 1     seq: 1     cat: source     description: Member - r2:     id: 2     seq: 2     cat: source     description: Friends or Family - r3:     id: 3     seq: 3     cat: source     description: Book - r4:     id: 4     seq: 4     cat: source     description: Search Engine - r5:     id: 5     seq: 5     cat: source     description: Magazine - r6:     id: 6     seq: 6     cat: source     description: Other