#303 new
Michael Klishin (antares)

belongs_to uses class name for default FK

Reported by Michael Klishin (antares) | May 22nd, 2008 @ 05:26 PM

Say I have the following in my DM 0.9 model:

belongs_to :provider, :class_name => "Company"

Unless I specify child_key, DM looks for company_id. ActiveRecord people once decided it would be simpler to swap association implementation if association name is used for default foreign key.

It is pretty important for polymorphic associations as well: implementation with association name based FK and Discriminator would require it to make things reasonable and simple to implement.

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins