Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Foxy fixtures can't handle custom primary keys

#1358

I have a model (Zip) with a custom primary key (code) and a :has_and_belongs_to_many association (City). The association works fine but I can't load fixtures with the new 2.0 way.

Way I tried:

zips.yml

zip12345:
  code: 12345
  cities: saloniki

cities.yml

saloniki:
  name: saloniki
  zips: zip12345

Unfortunately, this does not work, so I was forced to use the old and trusted way of manually writing the join table. I also tried omitting the code attribute from the fixtures (in case rails wants to auto create it) but no luck.

Reported by Kostas K. · November 12th, 2008 @ 10:57 AM

State: stale
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. Pratik
    Pratik
    • State changed from new to incomplete

    Is this still an issue ? Could you please submit a failing test ?

    Thanks.

    March 12th, 2009 @ 03:54 PM

  2. Matt Kern
    Matt Kern

    Loading fixtures in the test environment works fine for me, but strangely when I try to run "RAILS_ENV=development rake db:load:fixtures" it fails.

    I'll see if I cant come up with a test case to show the behavior.

    April 12th, 2009 @ 10:52 PM

  3. Matt Kern
    Matt Kern

    Er, that was db:fixtures:load above...

    April 12th, 2009 @ 10:55 PM

  4. CancelProfileIsBroken
  5. Gaius Centus Novus
    Gaius Centus Novus

    I believe the problem is that find(x) calls find(:first, :conditions => { :id => x}), when istead it should call find(:first, :conditions => { self.primary_key => x })

    September 28th, 2009 @ 01:43 AM

  6. Gaius Centus Novus
    Gaius Centus Novus

    I was wrong about the problem, but there's definitely something odd going on. I get odd foreign keys loaded from String-keyed fixtures. Needs further investigation.

    September 28th, 2009 @ 02:06 AM

  7. Rizwan Reza
  8. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  9. Santiago Pastorino
    Santiago Pastorino
    • State changed from incomplete to open
    • Importance changed from to

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 05:04 PM

  10. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 05:04 PM