# Setting Primary Key (\`id\` field) with fixtures

**URL:** <https://www.ruby-forum.com/t/setting-primary-key-id-field-with-fixtures/111967>\
**Category:** Rails\
**Created:** [August 13, 2007, 10:50pm UTC](https://www.ruby-forum.com/t/setting-primary-key-id-field-with-fixtures/111967 "2007-08-13T22:50:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_Von\_Girderboot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/9fc348/32.png) [@Ivan\_Von\_Girderboot](https://www.ruby-forum.com/u/Ivan_Von_Girderboot)\
**Post date:** [August 13, 2007, 10:50pm UTC](https://www.ruby-forum.com/t/setting-primary-key-id-field-with-fixtures/111967/1 "2007-08-13T22:50:08Z")

</div>

Is there any way to explicitly set the id of an fixture entry? i  
tried adding id: 1 to the attributes list in the .yml file, but it  
seems to get ignored.

example .yml file:

default\_user:  
id: 1  
name: Default User  
otherfield: stuff

nextuser:  
etc…

---

<div class="post-metadata">

**Author:** ![Ivan\_Von\_Girderboot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/9fc348/32.png) [@Ivan\_Von\_Girderboot](https://www.ruby-forum.com/u/Ivan_Von_Girderboot)\
**Post date:** [August 13, 2007, 11:34pm UTC](https://www.ruby-forum.com/t/setting-primary-key-id-field-with-fixtures/111967/2 "2007-08-13T23:34:18Z")

</div>

Hi Ivan,

Ivan Von Girderboot wrote:

> Is there any way to explicitly set the id of an fixture entry? i  
> tried adding id: 1 to the attributes list in the .yml file, but it  
> seems to get ignored.

What do you mean ‘get ignored’? What happens that makes you think so?

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![Ivan\_Von\_Girderboot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/9fc348/32.png) [@Ivan\_Von\_Girderboot](https://www.ruby-forum.com/u/Ivan_Von_Girderboot)\
**Post date:** [August 13, 2007, 11:56pm UTC](https://www.ruby-forum.com/t/setting-primary-key-id-field-with-fixtures/111967/3 "2007-08-13T23:56:25Z")

</div>

Hey Ivan, could you provide the actual message that you’re seeing and  
any  
additional relevant details so that we can better assist you?  
Thanks in advance,

-Conrad
