I am using a specific seed.rb script to seed the database from
scratch , as it clean the tables it's not so important, the id auto-
generated in sequence.
If the table is not empty (let's assume 12 records) , then the first
hash will have the id : 13 despite the fact that there is an "id" key
in the hash .. I should take off the auto-generation of the id
Maybe this is a bug (or undocumented feature) in YAML.
I have a similar problem in Rails (but ActiveRecord is not involved in
this workflow):
I YAML.dump a Hash that contains attributes
that I want to pass to a MyModel#new method. But when I YAML.load the
resulting yaml, the key :id is not in the Hash anymore! I tried to
reproduce this behavior with a simpler Hash, but i wasn't able to.
My current workaround is to rename the key ":id" to ":_id" before
dumping and rename it back after loading...