rails3-jquery-autocomplete-moc 0.1.0 → 0.3.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/.gitignore CHANGED
@@ -18,7 +18,8 @@ coverage
18
18
  rdoc
19
19
  pkg
20
20
  tmp
21
+ nbproject
21
22
 
22
23
  ## PROJECT::SPECIFIC
23
24
  .bundle
24
- .rvmrc
25
+ .rvmrc
data/Gemfile.lock CHANGED
@@ -48,7 +48,7 @@ GEM
48
48
  mime-types (1.16)
49
49
  polyglot (0.3.1)
50
50
  rack (1.2.1)
51
- rack-mount (0.6.12)
51
+ rack-mount (0.6.13)
52
52
  rack (>= 1.0.0)
53
53
  rack-test (0.5.4)
54
54
  rack (>= 1.0)
@@ -70,14 +70,14 @@ GEM
70
70
  ruby2ruby (~> 1.2)
71
71
  ruby_parser (~> 2.0)
72
72
  sexp_processor (~> 3.0)
73
- ruby2ruby (1.2.4)
73
+ ruby2ruby (1.2.5)
74
74
  ruby_parser (~> 2.0)
75
75
  sexp_processor (~> 3.0)
76
- ruby_parser (2.0.4)
76
+ ruby_parser (2.0.5)
77
77
  sexp_processor (~> 3.0)
78
78
  rubyforge (2.0.4)
79
79
  json_pure (>= 1.1.7)
80
- sexp_processor (3.0.4)
80
+ sexp_processor (3.0.5)
81
81
  sqlite3-ruby (1.3.1)
82
82
  thor (0.14.0)
83
83
  treetop (1.4.8)
data/README.markdown CHANGED
@@ -1,148 +1,5 @@
1
- # rails3-jquery-autocomplete
1
+ # rails3-jquery-autocomplete-moc
2
2
 
3
- An easy way to use jQuery's autocomplete with Rails 3. You can find a [detailed example](http://github.com/crowdint/rails3-jquery-autocomplete-app)
4
- on how to use this gem [here](http://github.com/crowdint/rails3-jquery-autocomplete-app).
5
3
 
6
- ## Before you start
4
+ fork of rails3-jquery-autocomplete
7
5
 
8
- Make sure your project is using jQuery-ui with the autocomplete widget
9
- before you continue.
10
-
11
- You can find more info about that here:
12
-
13
- * http://jquery.com/
14
- * http://jqueryui.com/demos/autocomplete/
15
- * http://github.com/rails/jquery-ujs
16
-
17
- I'd encourage you to understand how to use those 3 amazing tools before attempting to use this gem.
18
-
19
- ## Installing
20
-
21
- Include the gem on your Gemfile
22
-
23
- gem 'rails3-jquery-autocomplete', '>= 0.2.0'
24
-
25
- Install it
26
-
27
- bundle install
28
-
29
- Run the generator
30
-
31
- rails generate autocomplete
32
-
33
- And include autocomplete-rails.js on your layouts
34
-
35
- javascript_include_tag "autocomplete-rails.js"
36
-
37
- ## Usage
38
-
39
- ### Model Example
40
-
41
- Assuming you have a Brand model:
42
-
43
- class Brand < ActiveRecord::Base
44
- end
45
-
46
- create_table :brand do |t|
47
- t.column :name, :string
48
- end
49
-
50
- ### Controller
51
-
52
- To set up the required action on your controller, all you have to do is call it with the class name and the method
53
- as in the following example:
54
-
55
- class ProductsController < Admin::BaseController
56
- autocomplete :brand, :name
57
- end
58
-
59
- This will create an action _autocomplete_brand_name_ on your controller, don't forget to add it on your routes file
60
-
61
- resources :products do
62
- get :autocomplete_brand_name, :on => :collection
63
- end
64
-
65
- ### Options
66
-
67
- #### :full => true
68
-
69
- By default, the search starts from the beginning of the string you're searching for. If you want to do a full search, set the _full_ parameter to true.
70
-
71
- class ProductsController < Admin::BaseController
72
- autocomplete :brand, :name, :full => true
73
- end
74
-
75
- The following terms would match the query 'un':
76
-
77
- * Luna
78
- * Unacceptable
79
- * Rerun
80
-
81
- #### :full => false (default behavior)
82
-
83
- Only the following terms mould match the query 'un':
84
-
85
- * Unacceptable
86
-
87
- #### :display_value
88
-
89
- If you want to display a different version of what you're looking for, you can use the :display_value option.
90
-
91
- This options receives a method name as the parameter, and that method will be called on the instance when displaying the results.
92
-
93
- class Brand < ActiveRecord::Base
94
- def funky_method
95
- "#{self.name}.camelize"
96
- end
97
- end
98
-
99
-
100
- class ProductsController < Admin::BaseController
101
- autocomplete :brand, :name, :display_value => :funky_method
102
- end
103
-
104
- In the example above, you will search by _name_, but the autocomplete list will display the result of _funky_method_
105
-
106
- This wouldn't really make much sense unless you use it with the :id_element HTML tag. (See below)
107
-
108
- ### View
109
-
110
- On your view, all you have to do is include the attribute autocomplete on the text field
111
- using the url to the autocomplete action as the value.
112
- form_for @product do |f|
113
- f.text_field :brand_name, :autocomplete => autocomplete_brand_name_products_path
114
- end
115
-
116
- This will generate an HTML tag that looks like:
117
-
118
- <input type="text" autocomplete="products/autocomplete_brand_name">
119
-
120
- Now your autocomplete JS code is unobtrusive, Rails 3 style.
121
-
122
- ### Getting the object id
123
-
124
- If you need to use the id of the selected object, you can use the *:id_element* HTML tag too:
125
-
126
- f.text_field :brand_name, :autocomplete => autocomplete_brand_name_products_path, :id_element => '#some_element'
127
-
128
- This will update the field with id *#some_element with the id of the selected object. The value for this option can be any jQuery selector.
129
-
130
- ## Development
131
-
132
- If you want to make changes to the gem, first install bundler 1.0.0:
133
-
134
- gem install bundler --pre
135
-
136
- And then, install all your dependencies:
137
-
138
- bundle install
139
-
140
- ### Running the test suite
141
-
142
- rake test
143
-
144
- # About the Author
145
-
146
- [Crowd Interactive](http://www.crowdint.com) is an American web design and development company that happens to work in Colima, Mexico.
147
- We specialize in building and growing online retail stores. We don’t work with everyone – just companies we believe in. Call us today to see if there’s a fit.
148
- Find more info [here](http://www.crowdint.com)!
data/Rakefile CHANGED
@@ -51,7 +51,7 @@ Rake::RDocTask.new do |rdoc|
51
51
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
52
52
 
53
53
  rdoc.rdoc_dir = 'rdoc'
54
- rdoc.title = "rails3-jquery-autocomplete #{version}"
54
+ rdoc.title = "rails3-jquery-autocomplete-moc #{version}"
55
55
  rdoc.rdoc_files.include('README*')
56
56
  rdoc.rdoc_files.include('lib/**/*.rb')
57
57
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.3.0
@@ -1,4 +1,4 @@
1
- module Rails3JQueryAutocomplete
1
+ module Rails3JQueryAutocompleteMoc
2
2
  def self.included(base)
3
3
  base.extend(ClassMethods)
4
4
  end
@@ -30,22 +30,27 @@ module Rails3JQueryAutocomplete
30
30
 
31
31
  define_method("autocomplete_#{object}_#{method}") do
32
32
  unless params[:term] && params[:term].empty?
33
- items = object.to_s.camelize.constantize.where(["LOWER(#{method}) LIKE ?", "#{(options[:full] ? '%' : '')}#{params[:term].downcase}%"]).limit(limit).order(order)
33
+ unless object == "quick_search_term".to_sym
34
+ items = object.to_s.camelize.constantize.where(["LOWER(#{method}) LIKE ?", "#{(options[:full] ? '%' : '')}#{params[:term].downcase}%"]).limit(limit).order(order)
35
+ else
36
+ items = QuickSearchTerm.terms_for_search_string(params[:term]).limit(limit)
37
+ end
38
+
34
39
  else
35
40
  items = {}
36
41
  end
37
42
 
38
- render :json => json_for_autocomplete(items, (options[:display_value] ? options[:display_value] : method))
43
+ render :json => json_for_autocomplete(items, (options[:display_value] ? options[:display_value] : method),(options[:value] ? options[:value] : method))
39
44
  end
40
45
  end
41
46
  end
42
47
 
43
48
  private
44
- def json_for_autocomplete(items, method)
45
- items.collect {|i| {"id" => i.id, "label" => i.send(method), "value" => i.send(method)}}
49
+ def json_for_autocomplete(items, label, value)
50
+ items.collect {|i| {"id" => i.id, "label" => i.send(label), "value" => i.send(value)}}
46
51
  end
47
52
  end
48
53
 
49
54
  class ActionController::Base
50
- include Rails3JQueryAutocomplete
51
- end
55
+ include Rails3JQueryAutocompleteMoc
56
+ end
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{rails3-jquery-autocomplete}
8
- s.version = "0.2.3"
7
+ s.name = %q{rails3-jquery-autocomplete-moc}
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["David Padilla"]
12
- s.date = %q{2010-08-31}
13
- s.description = %q{Use jQuery's autocomplete plugin with Rails 3.}
14
- s.email = %q{david.padilla@crowdint.com}
11
+ s.authors = ["doug schlenker"]
12
+ s.date = %q{2010-09-14}
13
+ s.description = %q{Adapted from dabit's rails3-jquery-autocomplete for Moving Off Campus}
14
+ s.email = %q{doug@adeviasoftware.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.markdown"
@@ -27,21 +27,22 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "lib/generators/autocomplete_generator.rb",
29
29
  "lib/generators/templates/autocomplete-rails.js",
30
- "lib/rails3-jquery-autocomplete.rb",
31
- "rails3-jquery-autocomplete.gemspec",
30
+ "lib/rails3-jquery-autocomplete-moc.rb",
31
+ "rails3-jquery-autocomplete-moc.gemspec",
32
32
  "test/autocomplete_generator_test.rb",
33
33
  "test/controller_module_test.rb",
34
34
  "test/test_helper.rb"
35
35
  ]
36
- s.homepage = %q{http://github.com/crowdint/rails3-jquery-autocomplete}
36
+ s.homepage = %q{http://github.com/adeviadoug/rails3-jquery-autocomplete-moc}
37
37
  s.rdoc_options = ["--charset=UTF-8"]
38
38
  s.require_paths = ["lib"]
39
+ s.rubyforge_project = %q{rails3-jquery-autocomplete-moc}
39
40
  s.rubygems_version = %q{1.3.7}
40
- s.summary = %q{Use jQuery's autocomplete plugin with Rails 3.}
41
+ s.summary = %q{Adaptation of rails3-jquery-autocomplete}
41
42
  s.test_files = [
42
- "test/autocomplete_generator_test.rb",
43
- "test/controller_module_test.rb",
44
- "test/test_helper.rb"
43
+ "test/test_helper.rb",
44
+ "test/autocomplete_generator_test.rb",
45
+ "test/controller_module_test.rb"
45
46
  ]
46
47
 
47
48
  if s.respond_to? :specification_version then
@@ -49,12 +50,12 @@ Gem::Specification.new do |s|
49
50
  s.specification_version = 3
50
51
 
51
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
- s.add_development_dependency(%q<rails>, [">= 3.0.0.rc2"])
53
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
53
54
  else
54
- s.add_dependency(%q<rails>, [">= 3.0.0.rc2"])
55
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
55
56
  end
56
57
  else
57
- s.add_dependency(%q<rails>, [">= 3.0.0.rc2"])
58
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
58
59
  end
59
60
  end
60
61
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails3-jquery-autocomplete-moc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 3
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - doug schlenker
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-06 00:00:00 -07:00
18
+ date: 2010-09-14 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -54,8 +54,8 @@ files:
54
54
  - VERSION
55
55
  - lib/generators/autocomplete_generator.rb
56
56
  - lib/generators/templates/autocomplete-rails.js
57
- - lib/rails3-jquery-autocomplete.rb
58
- - rails3-jquery-autocomplete.gemspec
57
+ - lib/rails3-jquery-autocomplete-moc.rb
58
+ - rails3-jquery-autocomplete-moc.gemspec
59
59
  - test/autocomplete_generator_test.rb
60
60
  - test/controller_module_test.rb
61
61
  - test/test_helper.rb