Perhaps not a rails-core topic.... but... I've done this before in a plugin I've done called grouped_scope. Links below. In fact I did exactly what you mentioned, just method chained construct_sql. Check if out if you want.
http://github.com/metaskills/grouped_scope/tree/master http://www.metaskills.net/2008/9/28/jack-has_many-things - Ken On Nov 19, 2008, at 4:47 PM, Norm wrote: > > I'm working on a plug-in that will allow has_many associations to > ignore the foreign key. This may sound silly, but there are situations > where you'd like to join on something other than a single foreign key. > Right now, I can configure :conditions for the association, but these > are in addition to the existing foreign key. > > My plug-in would do something akin to http://pastie.org/319143. This > is really just pseudo-code, I haven't tested it yet. > > So, two questions: > > - Am I the only one crazy enough to think something like this is > useful? > - How can a plugin monkey-patch ActiveRecord for this? Just override > the entire construct_sql method? > > Thanks for any advice, > > Norman > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
