tektsu (3) [Avatar] Offline
#1
In iteration 5, I have created the tasks, projects, and locations tables, which were populated with data from the fixtures. I'm surprised to find that the values in the id field for the record in these tables are quite large: 953125641 and 996332877. I would have expected them to be 1 and 2, and apparently so does the book.

What am I missing here?
tektsu (3) [Avatar] Offline
#2
Re: Large values for id
I found out what happened. The fixtures apparently do not get id fields generated automatically. It seems like the users table did -- is that possibly because of a difference in how the generate script was called? Anyway, if the id field is left out of the fixture, it seems to generate one based on a hash of the record's label.
peterarmstrong (94) [Avatar] Offline
#3
Re: Large values for id
Yeah, this is what's known as "foxy fixtures" (aka Rathole), which was made part of Rails 2. It's not a good practice to mix specifying ids and not specifying ids; this is an error on my part that I didn't remove the ids from the users fixture...

See
http://ryandaigle.com/articles/2007/10/26/what-s-new-in-edge-rails-fixtures-just-got-a-whole-lot-easier
for more information.
tektsu (3) [Avatar] Offline
#4
Re: Large values for id
Ah, It makes more sense now. smilie I was wondering what the point of doing this was, but the article explains it well.
Thanks