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

Okay, a bit more information. I have:

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

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

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=""></a>

Referenced by