Brad Greenlee
2008-Jun-03 20:19 UTC
Patch to add :primary_key option to has_many and has_one associations
Hey all. I''m pimping for a patch that my colleague, Andre Arko, submitted originally: http://rails.lighthouseapp.com/projects/8994/tickets/292-add-has_many-primary_key-option I extended it to work with has_one associations, too. We have a couple instances in our app where we need an association that isn''t keyed off the default primary key of the model. This patch allows you to use a :primary_key option to specify which key in the model should be used for the association. Cheers, -b --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
John D. Hume
2008-Jun-04 02:34 UTC
Re: Patch to add :primary_key option to has_many and has_one associations
This sounds like a good feature, but isn''t "primary_key" a confusing choice of names for that option? What about "alternate_key"? -hume. On Tue, Jun 3, 2008 at 4:19 PM, Brad Greenlee <brad@wesabe.com> wrote:> http://rails.lighthouseapp.com/projects/8994/tickets/292-add-has_many-primary_key-option > > ... This patch allows you to use > a :primary_key option to specify which key in the model should be used > for the association.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Brad Greenlee
2008-Jun-04 04:28 UTC
Re: Patch to add :primary_key option to has_many and has_one associations
Yeah, I was thinking that myself. What about just :key? -b On Jun 3, 2008, at 7:34 PM, John D. Hume wrote:> > This sounds like a good feature, but isn''t "primary_key" a confusing > choice of names for that option? What about "alternate_key"? > -hume. > > On Tue, Jun 3, 2008 at 4:19 PM, Brad Greenlee <brad@wesabe.com> wrote: >> http://rails.lighthouseapp.com/projects/8994/tickets/292-add-has_many-primary_key-option >> >> ... This patch allows you to use >> a :primary_key option to specify which key in the model should be >> used >> for the association. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---