This project is archived and is in readonly mode.

Foxy fixtures can't handle custom primary keys
Reported by Kostas K. | November 12th, 2008 @ 10:57 AM | in 3.x
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.
Comments and changes to this ticket
- 
         Pratik March 12th, 2009 @ 03:54 PM- State changed from new to incomplete
 Is this still an issue ? Could you please submit a failing test ? Thanks. 
- 
            
         Matt Kern April 12th, 2009 @ 10:52 PMLoading 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. 
- 
            
         
- 
         CancelProfileIsBroken August 6th, 2009 @ 01:42 PM- Tag set to bugmash
 
- 
            
         Gaius Centus Novus September 28th, 2009 @ 01:43 AMI believe the problem is that find(x)callsfind(:first, :conditions => { :id => x}), when istead it should callfind(:first, :conditions => { self.primary_key => x })
- 
            
         Gaius Centus Novus September 28th, 2009 @ 02:06 AMI 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. 
- 
         
- 
         
- 
         Santiago Pastorino February 2nd, 2011 @ 05:04 PM- 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. 
- 
         Santiago Pastorino February 2nd, 2011 @ 05:04 PM- State changed from open to stale
 
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
 Betelgeuse
      Betelgeuse
 CancelProfileIsBroken
      CancelProfileIsBroken
 Pratik
      Pratik