[Rails-core] Re: has_many :through scoped association

2009-06-15 Thread Chris
findchris, I'm a bit reluctant to put my patch up for serious consideration because it currently lacks tests and would rightfully get slapped down pretty quickly. Care to try your hand at writing the tests? I'd be willing to patchify my solution sometime in the next two or three weeks if that wo

[Rails-core] Re: has_many :through scoped association

2009-06-15 Thread Chris
Peter, Not sure how I missed your message Anyway, my decision to reference a scope on the join model was easy: if it's referenced on the target their is confusion/ambiguity should you also desire a scope on the target model. For example... class User < AR::Base has_many :contracts has_

[Rails-core] Re: has_many :through scoped association

2009-06-15 Thread findchris
You might try updating the lighthouse ticket with this patch to try to drum up support. Seems quite useful. +1 On Apr 22, 8:39 am, Chris Cruft wrote: > I've expanded my monkey patch (see it here:http://gist.github.com/88448) > to the point where I wouldn't call it proof of concept anymore.  It

[Rails-core] Re: has_many :through scoped association

2009-05-01 Thread Peter Gumeson
Beautiful! This is exactly what I was looking for. Just thought I would give you guys some positive reinforcement about how useful this is so that it doesn't get lost in the shuffle. I see this version requires the scopes to be defined in the join model? I also had the same reaction that they sh

[Rails-core] Re: has_many :through scoped association

2009-04-22 Thread Chris Cruft
I've expanded my monkey patch (see it here: http://gist.github.com/88448) to the point where I wouldn't call it proof of concept anymore. It works very nicely in practice as well. The concept of scoped associations and composing of scopes, regardless of my implementation, seems strong. Luke, I

[Rails-core] Re: has_many :through scoped association

2009-03-31 Thread Chris Cruft
And here is the monkey patch for getting scoped join models (and targets): http://gist.github.com/88448 This is a "proof of concept" patch. It only scopes has_many associations (and has_many/has_one :through => indirectly). Scoping has_one should be a trivial matter of adding :scope as a va

[Rails-core] Re: has_many :through scoped association

2009-03-31 Thread Chris Cruft
The named_scope macro introduces a concise syntax for a complex set of [:order, :conditions, :joins, :include, :offset, :limit, :readonly] options for a model class. The options for the association macros use most of those SAME OPTIONS. My first suggestion is that association macros accept a :sc

[Rails-core] Re: has_many :through scoped association

2009-03-27 Thread Erik Andrejko
There is supposed to be a rewrite in the near future of Actiive Record's with_scope which is the underlying implementation mechanism for named_scopes. It would probably be a good idea to create a ticket in Lighthouse with a patch with failing tests so that they can be addressed when the rewrite h

[Rails-core] Re: has_many :through scoped association

2009-03-27 Thread Chris Cruft
This thread risks getting stale, which would be a shame because the need is obvious and we've got a couple of good proposals on the table. I took the time to more carefully review Ryan's proposed syntax, and I'm loving it. I will try to work up an implementation but I'll probably need someone el

[Rails-core] Re: has_many :through scoped association

2009-02-28 Thread Chris Cruft
I'm liking all of this goodness. I suspect that the syntax of Ryan's solution will be more appealing to most. On Feb 27, 1:45 pm, Ryan Bates wrote: > -1 on inheritance solution. It is creative, but I imagine that can get > messy very quickly if you have multiple attributes you're trying to do >