Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/caboose/engine.rb

Class Method Summary collapse

Class Method Details

.pluq(field, compact = true, sort = true) ⇒ Object

(PLU)cks a single uni(Q)ue field



9
10
11
12
13
14
15
# File 'lib/caboose/engine.rb', line 9

def self.pluq(field, compact = true, sort = true)    
  arr = self.uniq.pluck(field)
  return [] if arr.nil?
  arr = arr.compact if compact
  arr = arr.sort if sort
  return arr
end