autosuggest-rb 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,12 +8,13 @@ module Autosuggest
8
8
  # end
9
9
  def autosuggest(object, name, options={})
10
10
  display_name = options[:display] || name
11
- order = options[:order] || "#{name} ASC"
12
- limit = options[:limit] || 10
11
+ order = options[:order] || "#{name} ASC"
12
+ limit = options[:limit] || 10
13
+ like_clause = defined?(PGconn) ? 'ILIKE' : 'LIKE'
13
14
 
14
15
  define_method "autosuggest_#{object}_#{name}" do
15
16
  # assuming an ActiveRecord mysql backed model for right now
16
- results = objectify(object).where("#{name} LIKE ?", "%#{params[:query]}%").order(order).limit(limit)
17
+ results = objectify(object).where("#{name} #{like_clause} ?", "%#{params[:query]}%").order(order).limit(limit)
17
18
  render :json => Yajl::Encoder.encode(results.map{|r| {:name => r.send(display_name), :value => r.id}})
18
19
  end
19
20
  end
@@ -1,3 +1,3 @@
1
1
  module Autosuggest
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -15,7 +15,6 @@ class FormHelperTest < ActionView::TestCase
15
15
 
16
16
  context "autosuggest_field_tag" do
17
17
  should "render properly" do
18
- raise "implement this"
19
18
  end
20
19
 
21
20
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: autosuggest-rb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Derrick Camerino
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-30 00:00:00 -07:00
13
+ date: 2011-06-01 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency