This project is archived and is in readonly mode.
Named Scope does not respond to array method find_all
-
Brad Sumersford
Not sure why it puts a semicolon after the & in a highlighted source code section,
-
Brad Sumersford
Just using Topic.base.select(&:approved) would be a better workaround, but I still like my find_all :)
-
Ryan Bates
- Tag set to activerecord, named_scope, patch
Here's an attached patch which just modifies the regular expression.
Speaking of which, I don't care for that regular expression. It has some bad side effects like this, and it just looks ugly. Anyone have an idea for a refactoring?
-
Brad Sumersford
Ryan, the problem with the patch you submitted, it will not trap any of the find_by_* varieties. Leads back to your point about the regular expression being ugly and the side effects that come with it.
-
Ryan Bates
Brad, are you certain? For one thing find_by uses method missing, so they aren't really methods. Another thing is that we're looping through the methods on Array here, not methods on models. There are only two methods with "find" in them in Array:
[].methods.grep(/find/) # => ["find", "find_all"] -
Brad Sumersford
Ryan, you are correct, I was just seeing any potential method (from monkey patching array before named_scope is evaluated) and not just array methods when I thought of that. But that's really a fringe case and not applicable.
Thanks.
-
Repository
- State changed from new to resolved
(from [2415652660242d6b0da97119c562ecff82928575]) Support find_all on named scopes. [#730 Named Scope does not respond to array method find_all state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...
-
Repository
(from [38a0d5c0c7a37e22f9376c7cc363f4cf4f19a3d4]) Support find_all on named scopes. [#730 Named Scope does not respond to array method find_all state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...
