Module: Netzke::ActiveRecord::ComboboxOptions::ClassMethods

Defined in:
lib/netzke/active_record/combobox_options.rb

Instance Method Summary collapse

Instance Method Details

#netzke_combo_options_for(column, query = "") ⇒ Object



5
6
7
8
# File 'lib/netzke/active_record/combobox_options.rb', line 5

def netzke_combo_options_for(column, query = "")
  records = query.empty? ? find_by_sql("select distinct #{column} from #{table_name}") : find_by_sql("select distinct #{column} from #{table_name} where #{column} like '#{query}%'")
  records.map{|r| r.send(column)}
end