Sha256: f439a648691fea61b8bee4328fca4625803ccffe878aebff384f5720164c1214
Contents?: true
Size: 497 Bytes
Versions: 2
Compression:
Stored size: 497 Bytes
Contents
module Netzke::ActiveRecord::ComboboxOptions module ClassMethods # TODO: rename to netzke_options_for (to avoid naming conflicts) def 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 end def self.included(receiver) receiver.extend ClassMethods end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
netzke-basepack-0.5.14 | lib/netzke/active_record/combobox_options.rb |
netzke-basepack-0.5.13 | lib/netzke/active_record/combobox_options.rb |