#303 ✓resolved
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 Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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