Sha256: 719b1b0976940606bbc75a2256a80b287a53189930005ad8cefc2a82d91e4c9b

Contents?: true

Size: 507 Bytes

Versions: 12

Compression:

Stored size: 507 Bytes

Contents

module Netzke
  module ActiveRecord
    module ComboboxOptions
      module ClassMethods
        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
      end

      def self.included(receiver)
        receiver.extend         ClassMethods
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
netzke-basepack-0.7.7 lib/netzke/active_record/combobox_options.rb
netzke-basepack-zh-0.7.6 lib/netzke/active_record/combobox_options.rb
netzke-basepack-0.7.6 lib/netzke/active_record/combobox_options.rb
netzke-basepack-0.7.5 lib/netzke/active_record/combobox_options.rb
netzke-basepack-0.7.4 lib/netzke/active_record/combobox_options.rb
netzke-basepack-0.7.3 lib/netzke/active_record/combobox_options.rb
netzke-basepack-0.7.2 lib/netzke/active_record/combobox_options.rb
netzke-basepack-0.7.1 lib/netzke/active_record/combobox_options.rb
netzke-basepack-0.6.5 lib/netzke/active_record/combobox_options.rb
netzke-basepack-0.7.0 lib/netzke/active_record/combobox_options.rb
netzke-basepack-0.6.4 lib/netzke/active_record/combobox_options.rb
netzke-basepack-0.6.3 lib/netzke/active_record/combobox_options.rb