Inconsistent auto generated fixture IDs

I'm having an issue where the auto generated IDs in the fixtures are inconsistent from my machine to that of the other developers working on the project. The main difference between between the machines is that I'm running Snow Leopard and I think everyone else is on Leopard.

We're using factories to generate the fixtures so I don't know what label Rails is hashing to auto generate the ID.

Any help in debugging this would be greatly appreciated. Thanks in advance.

Why are you relying on the IDs from factories?

You should be using the returned objects to get the records and having the factories automatically set up associations.

If you mean Seed data (from seed.rb) then the IDs should be assigned from your database.

A bit confused as to what you’re trying to do with them…

Cheers,

Andy

Sorry, I just got my hands on this code for the first time a few days ago so I'm just learning it.

To give you an example:

The yml for the BlogPost factory contains a hardcoded author_id. That author_id is one that is apparently being auto generated by the Author factory and for the original team that's consistently working. Unfortunately, for myself, the ids being auto generated for the Author objects don't include the id hardcoded into the BlogPost factotry.

In previous versions of rails the autogenerated fixture is (basically) just the hash of the label (as in "foo".hash). The hash method is not guaranteed to be the same across different versions or builds of ruby, in particular 64 bit versions are different to 32bit (and in snow leopard ruby is a 64 bit app). Later versions of rails (don't remember the first) use a crc32, so that should be stable across different builds of ruby

I'm not sure why you care though

Fred

Exactly - the whole point of the auto-generated ids is to do things like this in the fixture:

author: somebody

Which references the *name* of the desired author fixture rather than the id.

--Matt Jones

I realize that, unfortunately I didn't write the tests and fixtures. I was just hoping there was a way I could get them to pass before I go through and change them.