Module: ActiveRecord::FinderMethods
- Defined in:
- lib/select-column/finder_methods.rb
Instance Method Summary collapse
Instance Method Details
#select_column(column_select = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/select-column/finder_methods.rb', line 4 def select_column(column_select=nil) self.select_values = if !column_select.nil? [ column_select ] elsif !select_values.nil? && !select_values.empty? [ select_values.first ] else [ :id ] end column = self.klass.columns_hash[select_values.first.to_s] self.klass.connection.select_values(self.to_sql).map { |value| column.type_cast(value) } end |