rails3-jquery-autocomplete 0.0.3 → 0.1.0
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.
- data/README.markdown +3 -3
- data/Rakefile +1 -1
- data/lib/autocomplete.rb +9 -4
- data/lib/generators/templates/autocomplete-rails.js +4 -2
- data/rails3-jquery-autocomplete.gemspec +2 -2
- metadata +4 -4
data/README.markdown
CHANGED
@@ -4,13 +4,13 @@ An easy way to use jQuery's autocomplete with Rails 3
|
|
4
4
|
|
5
5
|
## Before you start
|
6
6
|
|
7
|
-
Make sure your project is using jQuery
|
7
|
+
Make sure your project is using jQuery-ui with the autocomplete widget
|
8
8
|
before you continue.
|
9
9
|
|
10
10
|
You can find more info about that here:
|
11
11
|
|
12
12
|
* http://jquery.com/
|
13
|
-
* http://
|
13
|
+
* http://jqueryui.com/demos/autocomplete/
|
14
14
|
* http://github.com/rails/jquery-ujs
|
15
15
|
|
16
16
|
I'd recommend you understand what's happening with those 3 tools before attempting to use this gem.
|
@@ -19,7 +19,7 @@ I'd recommend you understand what's happening with those 3 tools before attempti
|
|
19
19
|
|
20
20
|
Include the gem on your Gemfile
|
21
21
|
|
22
|
-
gem 'rails3-jquery-autocomplete', '>= 0.0
|
22
|
+
gem 'rails3-jquery-autocomplete', '>= 0.1.0', :require => 'autocomplete'
|
23
23
|
|
24
24
|
Install it
|
25
25
|
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('rails3-jquery-autocomplete', '0.0
|
5
|
+
Echoe.new('rails3-jquery-autocomplete', '0.1.0') do |p|
|
6
6
|
p.description = "Use jQuery's autocomplete plugin with Rails 3."
|
7
7
|
p.url = "http://github.com/crowdint/rails3-jquery-autocomplete"
|
8
8
|
p.author = "David Padilla"
|
data/lib/autocomplete.rb
CHANGED
@@ -31,16 +31,21 @@ module Autocomplete
|
|
31
31
|
order = options[:order] || "#{method} ASC"
|
32
32
|
|
33
33
|
define_method("autocomplete_#{object}_#{method}") do
|
34
|
-
unless params[:
|
35
|
-
items = object.to_s.camelize.constantize.where(["LOWER(#{method}) LIKE ?", "#{params[:
|
34
|
+
unless params[:term] && params[:term].empty?
|
35
|
+
items = object.to_s.camelize.constantize.where(["LOWER(#{method}) LIKE ?", "#{params[:term]}%"]).limit(limit).order(order)
|
36
36
|
else
|
37
|
-
items =
|
37
|
+
items = {}
|
38
38
|
end
|
39
39
|
|
40
|
-
render :
|
40
|
+
render :json => json_for_autocomplete(items, method)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
def json_for_autocomplete(items, method)
|
47
|
+
items.collect {|i| {"id" => i.id, "label" => i[method], "value" => i[method]}}
|
48
|
+
end
|
44
49
|
end
|
45
50
|
|
46
51
|
class ActionController::Base
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rails3-jquery-autocomplete}
|
5
|
-
s.version = "0.0
|
5
|
+
s.version = "0.1.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["David Padilla"]
|
9
|
-
s.date = %q{2010-07-
|
9
|
+
s.date = %q{2010-07-15}
|
10
10
|
s.description = %q{Use jQuery's autocomplete plugin with Rails 3.}
|
11
11
|
s.email = %q{david@crowdint.com}
|
12
12
|
s.extra_rdoc_files = ["README.markdown", "lib/autocomplete.rb", "lib/generators/autocomplete_generator.rb", "lib/generators/templates/autocomplete-rails.js"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails3-jquery-autocomplete
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.3
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Padilla
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-15 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|