Skip to content

Instantly share code, notes, and snippets.

@invisiblefunnel
Last active December 21, 2015 23:29
Show Gist options
  • Select an option

  • Save invisiblefunnel/6382353 to your computer and use it in GitHub Desktop.

Select an option

Save invisiblefunnel/6382353 to your computer and use it in GitHub Desktop.
Pluck ordered, unique column values. Useful for select input collections.
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