Last active
December 21, 2015 23:29
-
-
Save invisiblefunnel/6382353 to your computer and use it in GitHub Desktop.
Pluck ordered, unique column values. Useful for select input collections.
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
| class ActiveRecord::Base | |
| def self.pluck_uniq(name, order = name) | |
| select(name.to_s).uniq.order(order).pluck(name.to_sym) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment