Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11404 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

[PATCH] Named Scope (aka has_finder)

Reported by: nkallen Assigned to: core
Priority: normal Milestone: 2.1
Component: ActiveRecord Version: edge
Severity: normal Keywords: named_scope
Cc:

Description

This is the functionality of has_finder, renamed 'Named Scope'. Full documentation for the original gem is here:

http://pivots.pivotallabs.com/users/nick/blog/articles/284-hasfinder-it-s-now-easier-than-ever-to-create-complex-re-usable-sql-queries

Some notes:

1. I've avoided alias_method_chaining #method_missing on AssociationCollection and HasManyAssociation for performance reasons, but the unit tests for this are with the rest of the Named Scope tests.

2. I couldn't decide whether Named Scope should be considered an Association.. For now I've kept it out of the associations module, but it resembles associations in many ways...

3. I gave some thought to keeping the testing strategy consistent with ActiveRecord, which required a total rewrite of my (Rspec) tests. In ActiveRecord, there are some places where tables and models are created in the test case, but mostly there are global models that are relied upon in many test cases. I went with the majority technique. Unfortunately I needed to add new fixtures which broke 16 other tests. So I rewrote most of them to be less brittle.

Attachments

named_scope.patch (26.7 kB) - added by nkallen on 03/23/08 01:34:04.

Change History

03/23/08 01:34:04 changed by nkallen

  • attachment named_scope.patch added.

03/24/08 02:50:05 changed by rick

  • status changed from new to closed.
  • resolution set to fixed.

(In [9084]) Merge the has_finder gem, renamed as 'named_scope'. Closes #11404 [nkallen]