This project is archived and is in readonly mode.

#6376 ✓resolved
Jon Leighton

has_many :through assoc_ids incorrect with :primary_key option on belongs_to source

Reported by Jon Leighton | February 5th, 2011 @ 08:39 AM | in 3.x

Initially reported in the comments at https://rails.lighthouseapp.com/projects/8994/tickets/2421-problem-...


Okay, a bit more information. I have:

class Phenotype
  has_many :observations
  has_many :genes, :through => :observations
end

class Observation
  belongs_to :gene, :primary_key => :entrez_id
end

It used to be that when I did Phenotype.find(48291).gene_ids, it would give me the entrez_id attribute rather than the primary keys. This makes sense. I don't use id for anything at all, which is why I set entrez_id as the primary. Unfortunately, in the current beta, gene_ids returns the :id attribute on each gene.

There are obvious workarounds, but this is obnoxious, and it can't be the correct behavior.


Comments and changes to this ticket

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>

Referenced by

Pages