Colin Law wrote: > On 17 August 2010 23:02, Marnen Laibow-Koser <li...@ruby-forum.com> > wrote: >> No. �Don't. �It's a bad idea. �It should never be necessary. �Did you >> read the link I posted? > > Marnen, I am not sure what you are saying should never be necessary. > Suppose I have named_scope_a and named_scope_b. Are you saying it > should never be necessary to find the set of records that includes all > those in _a and those in _b?
No. I am saying that it should never be possible -- or necessary -- to do Person.scope_a.and_some_more_records . IMHO, that defeats the purpose of named_scopes, because the results of the scope chain are no longer guaranteed to be within scope_a. That's dangerous. If this syntax were possible, then there would be no obvious difference between a proper chain like Person.red_hair.blue_eyes and an improper chain like Person.red_hair.oh_and_everyone_else_too. > If not that then what is the best way? > To provide a new named scope for the OR condition does not seem very > DRY. It's a completely different scope from either of its constituents. What's repetitive about that, particularly if you factor out duplication in other ways? I'd actually support a syntax for union queries such as Person.union_scope(:scope_a, :scope_b). This makes it obvious that it is not a simple scope chain, while still being simple to call. > > Colin Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.