# Fixtures Error With Rails 2.1 (and 2.0.2)

**URL:** <https://www.ruby-forum.com/t/fixtures-error-with-rails-2-1-and-2-0-2/139453>\
**Category:** Rails\
**Created:** [June 4, 2008, 1:02am UTC](https://www.ruby-forum.com/t/fixtures-error-with-rails-2-1-and-2-0-2/139453 "2008-06-04T01:02:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@Derek\_P](https://www.ruby-forum.com/u/Derek_P)\
**Post date:** [June 4, 2008, 1:02am UTC](https://www.ruby-forum.com/t/fixtures-error-with-rails-2-1-and-2-0-2/139453/1 "2008-06-04T01:02:26Z")

</div>

I have begun to use the reference function feature of sexy migrations,  
and I have noticed that the fixtures are actually not playing nice  
with this new feature.

If I create a model, whose table has this line:  
t.reference :user

the fixure will look like

one:  
user:

when it should be user\_id, now, it may be possible (I don’t know, to  
define an object in the fixtures now, but when I run my unit tests I  
get an error trying to populate a ‘user’ field in my database that  
does not exist. So, that seems to me like its not being very  
intelligent.

…or am I missing something?

---

<div class="post-metadata">

**Author:** ![Derek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@Derek\_P](https://www.ruby-forum.com/u/Derek_P)\
**Post date:** [June 4, 2008, 1:04am UTC](https://www.ruby-forum.com/t/fixtures-error-with-rails-2-1-and-2-0-2/139453/2 "2008-06-04T01:04:48Z")

</div>

On Jun 4, 12:01 am, “Derek P.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> user:

Just user: is fine, as long as that model as a belongs\_to :user

Fred

---

<div class="post-metadata">

**Author:** ![Derek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@Derek\_P](https://www.ruby-forum.com/u/Derek_P)\
**Post date:** [June 4, 2008, 1:13am UTC](https://www.ruby-forum.com/t/fixtures-error-with-rails-2-1-and-2-0-2/139453/3 "2008-06-04T01:13:02Z")

</div>

t.references (not reference)

---

<div class="post-metadata">

**Author:** ![Derek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@Derek\_P](https://www.ruby-forum.com/u/Derek_P)\
**Post date:** [June 4, 2008, 1:13am UTC](https://www.ruby-forum.com/t/fixtures-error-with-rails-2-1-and-2-0-2/139453/4 "2008-06-04T01:13:37Z")

</div>

t.reference is working for me 😕  
ie: I am actually getting the proper foreign key created and  
everything.

I may not have had the belongs\_to though, good call.
