Module: QuickSearch
- Defined in:
- lib/quick_search/active_record.rb,
lib/quick_search/version.rb
Overview
Powered By Urazov Marat Marat QuickSearch Lib for Abt module
Defined Under Namespace
Modules: InstanceMethods
Constant Summary collapse
- VERSION =
'0.0.1'
Instance Method Summary collapse
- #quick_search(options) ⇒ Object (also: #qs)
Instance Method Details
#quick_search(options) ⇒ Object Also known as: qs
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/quick_search/active_record.rb', line 4 def quick_search() scope :quick_search, lambda { |q_string| c = ARCondition.new(nil, "OR") [:fields].each do |field| c << ["#{field} ILIKE ? ", "%#{q_string}%"] end joins([:joins]).includes([:include]).where(c.conditions) if } #scope :qs, lambda{|q_string| guick_search(q_string) } scope :first_letter_search, lambda { |q_string| c = ARCondition.new(nil, "OR") [:fields].each do |field| c << ["#{field} ILIKE ? ", "#{q_string}%"] end joins([:joins]).includes([:include]).where(c.conditions) if } #scope :fls, lambda{|q_string| first_letter_search(q_string) } include InstanceMethods class << self alias_method :qs, :quick_search alias_method :fls, :first_letter_search end end |