Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 699343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:22:33+00:00 2026-05-14T03:22:33+00:00

In the documentation concerning Fixtures ( http://api.rubyonrails.org/classes/Fixtures.html ) they provide the following example of

  • 0

In the documentation concerning Fixtures (http://api.rubyonrails.org/classes/Fixtures.html) they provide the following example of using label references for associations:

### in pirates.yml
reginald:
  name: Reginald the Pirate
  monkey: george

### in monkeys.yml
george:
  name: George the Monkey
  pirate: reginald

So following their lead, I have a User model that has_one :profile, a Profile model that belongs_to :user, and tried to set up fixtures per their example:

### in users.yml
reginald:
  id: 1
  login: reginald

### in profiles.yml
reginalds_profile:
  id: 1
  name: Reginald the Pirate
  user: reginald

(Note: since my association is one-way, the User fixture doesn’t have a “profile: reginalds_profile” association–putting it in causes an error because the SQL table has no profile_id attribute.)

The problem is, in my unit tests everything seems to load correctly, but users(:reginald).profile is always nil. What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:22:33+00:00Added an answer on May 14, 2026 at 3:22 am

    Based on tadman’s suggestion I did some more searching and found the answer elsewhere on this site, so I might as well post it.

    See post titled Automatic associations in ruby on rails fixtures

    Apparently the way Rails finds associated fixtures when you use labels (user: reginald) instead of IDs (user_id: 1) is by hashing the name and assuming the hash is the ID. If you set the ID to something specific, this fails. But if you let Rails automatically assign IDs it uses that hashing scheme. So the documentation for fixture association labels is missing a key tidbit–if you are using labels you must avoid applying your own IDs in the fixtures to be matched. Fixtures not being matched by labels can still have whatever ID scheme you choose.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading this documentation page, http://developer.android.com/reference/android/util/Log.html . The section here caught my eye:
Documentation can be found here It says in the example: onDrop: Called whenever a
In Android documentation concerning code signing we can read: By signing multiple applications with
Okay. I've spent hours poring over the scattered FB documentation concerning xFBML, Open Graph,
My questions aims at the behaviour of setjmp/longjmp concerning local variables. Example code: jmp_buf
I've had a hard time finding references in the TR1 documentation concerning shared arrays.
I was reading some of the documentation on MSDN concerning do's and don't with
While there is quite a lot of documentation and example for creating templates in
I posted the following code on rosettacode.org for the task of converting Arabic and
I've seen that most of the documentation in the Liferay Wiki (concerning Eclipse plugins

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.