# Inconsistent auto generated fixture IDs

**URL:** <https://www.ruby-forum.com/t/inconsistent-auto-generated-fixture-ids/184206>\
**Category:** Rails\
**Created:** [February 26, 2010, 5:18pm UTC](https://www.ruby-forum.com/t/inconsistent-auto-generated-fixture-ids/184206 "2010-02-26T17:18:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![blim8183](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9bcb4/32.png) [@blim8183](https://www.ruby-forum.com/u/blim8183)\
**Post date:** [February 26, 2010, 5:18pm UTC](https://www.ruby-forum.com/t/inconsistent-auto-generated-fixture-ids/184206/1 "2010-02-26T17:18:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![blim8183](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9bcb4/32.png) [@blim8183](https://www.ruby-forum.com/u/blim8183)\
**Post date:** [February 26, 2010, 5:45pm UTC](https://www.ruby-forum.com/t/inconsistent-auto-generated-fixture-ids/184206/2 "2010-02-26T17:45:31Z")

</div>

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

–  
Andy J.  
[http://andyjeffries.co.uk/](http://andyjeffries.co.uk/)#rubyonrails #mysql #jquery  
Registered address: 64 Sish Lane, Stevenage, Herts, SG1 3LS  
Company number: 5452840

---

<div class="post-metadata">

**Author:** ![blim8183](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9bcb4/32.png) [@blim8183](https://www.ruby-forum.com/u/blim8183)\
**Post date:** [February 26, 2010, 5:52pm UTC](https://www.ruby-forum.com/t/inconsistent-auto-generated-fixture-ids/184206/3 "2010-02-26T17:52:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![blim8183](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9bcb4/32.png) [@blim8183](https://www.ruby-forum.com/u/blim8183)\
**Post date:** [February 26, 2010, 6:24pm UTC](https://www.ruby-forum.com/t/inconsistent-auto-generated-fixture-ids/184206/4 "2010-02-26T18:24:08Z")

</div>

On Feb 26, 4:17 pm, blim8183 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

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

---

<div class="post-metadata">

**Author:** ![blim8183](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9bcb4/32.png) [@blim8183](https://www.ruby-forum.com/u/blim8183)\
**Post date:** [March 1, 2010, 4:36pm UTC](https://www.ruby-forum.com/t/inconsistent-auto-generated-fixture-ids/184206/5 "2010-03-01T16:36:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![blim8183](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9bcb4/32.png) [@blim8183](https://www.ruby-forum.com/u/blim8183)\
**Post date:** [February 27, 2010, 7:33pm UTC](https://www.ruby-forum.com/t/inconsistent-auto-generated-fixture-ids/184206/6 "2010-02-27T19:33:29Z")

</div>

On Feb 26, 12:23 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

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