rails-simple-search 0.9.0 → 0.9.1
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 +6 -6
- data/lib/rails-simple-search.rb +9 -0
- metadata +20 -42
data/README
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
rails-simple-search
|
2
|
+
===================
|
3
3
|
|
4
|
-
|
4
|
+
rails-simple-search is a Ruby gem. It helps you quickly implement searching/filtering function for your web site.
|
5
5
|
This plugin has paginating feature built in. If you're not looking for a full-text searching solution, this plugin will
|
6
6
|
most probably satisfy all your searching requirement.
|
7
7
|
|
@@ -14,7 +14,7 @@ plugin, I usually do the searching in the following way:
|
|
14
14
|
4) Run the find(:all, :conditions => [xxxxxx], :joins => "yyyyyy") with the WHERE and JOIN clauses
|
15
15
|
|
16
16
|
After having used this pattern a few times, I realized I could DRY it to make future coding of this kind of searching
|
17
|
-
much simpler. That's where the
|
17
|
+
much simpler. That's where the rails-simple-search plugin comes in.
|
18
18
|
|
19
19
|
Now implementing the searching/filter page is a lot easier for me. You're see how easy it is by taking a look at the
|
20
20
|
following example. I may give more examples in the future when I have some spare time.
|
@@ -31,11 +31,11 @@ We'd like to find users according to any combination of the following criteria:
|
|
31
31
|
2) state of the user's address
|
32
32
|
3) part of the name of any authors who commented the user's any posts
|
33
33
|
|
34
|
-
The following is how we implement this searching function with
|
34
|
+
The following is how we implement this searching function with rails-simple-search:
|
35
35
|
|
36
36
|
Code in model (app/model/search.rb):
|
37
37
|
|
38
|
-
class Search <
|
38
|
+
class Search < RailsSimpleSearch::Base
|
39
39
|
end
|
40
40
|
|
41
41
|
Code in controller:
|
data/lib/rails-simple-search.rb
CHANGED
@@ -7,6 +7,15 @@ module RailsSimpleSearch
|
|
7
7
|
:per_page => 20
|
8
8
|
}
|
9
9
|
class Base
|
10
|
+
def self.inherited(subclass)
|
11
|
+
class << subclass
|
12
|
+
# in rails 3, the call to "form_for" invokes the mode_name
|
13
|
+
def model_name
|
14
|
+
ActiveModel::Name.new(self)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
10
19
|
def initialize(model_class, criteria, config={})
|
11
20
|
@model_class = (model_class.is_a?(Symbol) || model_class.is_a?(String))? model_class.to_s.camelize.constantize : model_class
|
12
21
|
@table_name = @model_class.table_name
|
metadata
CHANGED
@@ -1,68 +1,46 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-simple-search
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 9
|
9
|
-
- 0
|
10
|
-
version: 0.9.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Yi Zhang
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2012-03-11 00:00:00 -08:00
|
19
|
-
default_executable:
|
12
|
+
date: 2012-03-11 00:00:00.000000000Z
|
20
13
|
dependencies: []
|
21
|
-
|
22
|
-
description: A very simple and light get to quick build search function in rails
|
14
|
+
description: this version starts to support rails 3
|
23
15
|
email: yzhang.wa@gmail.com
|
24
16
|
executables: []
|
25
|
-
|
26
17
|
extensions: []
|
27
|
-
|
28
18
|
extra_rdoc_files: []
|
29
|
-
|
30
|
-
files:
|
19
|
+
files:
|
31
20
|
- README
|
32
21
|
- lib/rails-simple-search.rb
|
33
|
-
has_rdoc: true
|
34
22
|
homepage: http://github.com/yzhanginwa/rails-simple-search
|
35
23
|
licenses: []
|
36
|
-
|
37
24
|
post_install_message:
|
38
25
|
rdoc_options: []
|
39
|
-
|
40
|
-
require_paths:
|
26
|
+
require_paths:
|
41
27
|
- lib
|
42
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
29
|
none: false
|
44
|
-
requirements:
|
45
|
-
- -
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
|
48
|
-
|
49
|
-
- 0
|
50
|
-
version: "0"
|
51
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
35
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
segments:
|
58
|
-
- 0
|
59
|
-
version: "0"
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
60
40
|
requirements: []
|
61
|
-
|
62
41
|
rubyforge_project:
|
63
|
-
rubygems_version: 1.
|
42
|
+
rubygems_version: 1.8.15
|
64
43
|
signing_key:
|
65
44
|
specification_version: 3
|
66
|
-
summary:
|
45
|
+
summary: A very simple and light get to quick build search function in rails
|
67
46
|
test_files: []
|
68
|
-
|