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

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

Why are you relying on the IDs from factories?

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

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

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



Andy J. #rubyonrails #mysql #jquery
Registered address: 64 Sish Lane, Stevenage, Herts, SG1 3LS
Company number: 5452840

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.

On Feb 26, 4:17 pm, blim8183 [email protected] wrote:

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


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.

On Feb 26, 12:23 pm, Frederick C. [email protected]

I’m not sure why you care though

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 J.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs