Created
July 29, 2013 00:13
-
-
Save davetapley/6101402 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Works, but a bit awkward: | |
def self.group_by_name(r) | |
r.group_by &:name | |
end | |
Model.group_by_name(models.where(..)) | |
# Would be nicer to have | |
def self.group_by_name | |
group_by &:name | |
end | |
Model.where(..).group_by_name # but this gives: undefined method `group_by' for #<Class:' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I thought there was a method I could call which returns the chained relation, in the scope, on which I could call
.to_a.group_by ...
.