rails-simple-search 1.1.7 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.rdoc +7 -3
- data/lib/rails-simple-search.rb +9 -6
- data/lib/sql_handler.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c180305a173dc76d61b6bf88048d7b4071b374b0ca3d18e68179f57516e00bc8
|
4
|
+
data.tar.gz: 36296809170c80c856bb2b300663faae462a11c4fa211803d9386560d605ffba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a8d8986df1dc830c910f3812968102ab527d9b70fc6cc7d4d8e3550eeeb20b3334c6f1d4d51b06a4d86295dac99a16eb8e94d880f653dada4337244217b098c
|
7
|
+
data.tar.gz: c03cb28f7e8349be45aa3ff441d811fc4ab0b20b57951c41b7440daacdc9d1a48cbe018fb4d5166c61a9ee40b4d6b1efff46ddaeb60dcacee9eef28d33d8014b
|
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
=
|
1
|
+
=rails-simple-search
|
2
2
|
|
3
3
|
rails-simple-search is a Ruby gem. It helps you quickly implement searching/filtering function for your web site. This plugin has paginating feature built in. If you're not looking for a full-text searching solution, this plugin will most probably satisfy all your searching requirement.
|
4
4
|
|
@@ -41,7 +41,7 @@ The following is how we implement this searching function with rails-simple-sear
|
|
41
41
|
|
42
42
|
4. Code in views:
|
43
43
|
|
44
|
-
<% form_for @search, url => "/xxxxxx" do |f| %>
|
44
|
+
<% form_for @search, url => "/xxxxxx", data: {turbo: false} do |f| %>
|
45
45
|
|
46
46
|
<%=f.label :email %>
|
47
47
|
<%=f.text_field :email %>
|
@@ -69,7 +69,7 @@ The following is how we implement this searching function with rails-simple-sear
|
|
69
69
|
<% end %>
|
70
70
|
|
71
71
|
5. Add route for the post to url "/xxxxxx" (config/route.rb)
|
72
|
-
|
72
|
+
post "/xxxxxx" => "yyyyyyy#zzzzzz"
|
73
73
|
|
74
74
|
== Note
|
75
75
|
|
@@ -84,8 +84,12 @@ From version 1.1.0 on, we started to support the "or" relation, e.g., we can use
|
|
84
84
|
|
85
85
|
From version 1.1.3 on, we started to support Rails 5.
|
86
86
|
|
87
|
+
For Rails 7, please use version 1.1.7.
|
88
|
+
|
87
89
|
There is a real demo application which you can download and run immediately: https://github.com/yzhanginwa/demo_app_for_rails_simple_search
|
88
90
|
|
91
|
+
For Rails 7 demo, please see here: https://github.com/yzhanginwa/rails_simple_search_demo
|
92
|
+
|
89
93
|
== License
|
90
94
|
|
91
95
|
Copyright (c) 2012 [Yi Zhang], released under the MIT license
|
data/lib/rails-simple-search.rb
CHANGED
@@ -12,6 +12,8 @@ module RailsSimpleSearch
|
|
12
12
|
end
|
13
13
|
|
14
14
|
class Base
|
15
|
+
attr_reader :criteria
|
16
|
+
|
15
17
|
def self.inherited(subclass)
|
16
18
|
class << subclass
|
17
19
|
# in rails 3, the call to "form_for" invokes the model_name
|
@@ -25,11 +27,13 @@ module RailsSimpleSearch
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def self.pre_process(model_name, &procedure)
|
30
|
+
model_name.each { |internal_model_name| pre_process(internal_model_name, &procedure) } if model_name.is_a?(Array)
|
28
31
|
@pre_processors ||= {}
|
29
32
|
@pre_processors[model_name] = procedure
|
30
33
|
end
|
31
34
|
|
32
35
|
def self.pre_processor(model_name)
|
36
|
+
@pre_processors ||= {}
|
33
37
|
@pre_processors[model_name]
|
34
38
|
end
|
35
39
|
|
@@ -57,17 +61,16 @@ module RailsSimpleSearch
|
|
57
61
|
end
|
58
62
|
|
59
63
|
def add_conditions(h={})
|
60
|
-
@criteria.merge!(h)
|
64
|
+
@criteria.merge!(h.stringify_keys)
|
61
65
|
end
|
62
66
|
|
63
67
|
def remove_criteria(key)
|
64
|
-
|
65
|
-
@criteria.delete(key)
|
66
|
-
value
|
68
|
+
key.each { |internal_key| remove_criteria(internal_key) } if key.is_a?(Array)
|
69
|
+
@criteria.delete(key.to_s)
|
67
70
|
end
|
68
71
|
|
69
72
|
def append_criteria(key, value)
|
70
|
-
@criteria[key] = value
|
73
|
+
@criteria[key.to_s] = value
|
71
74
|
end
|
72
75
|
|
73
76
|
private
|
@@ -107,7 +110,7 @@ module RailsSimpleSearch
|
|
107
110
|
c[key] = value
|
108
111
|
end
|
109
112
|
end
|
110
|
-
c
|
113
|
+
c.stringify_keys
|
111
114
|
end
|
112
115
|
end
|
113
116
|
end
|
data/lib/sql_handler.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-simple-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yi Zhang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: rails-simple-search is a light and easy to use gem. It could help developers
|
14
14
|
quickly build a search page.
|
@@ -39,8 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
|
-
|
43
|
-
rubygems_version: 2.5.1
|
42
|
+
rubygems_version: 3.3.26
|
44
43
|
signing_key:
|
45
44
|
specification_version: 4
|
46
45
|
summary: A very simple and light gem to quickly build search/filter function in rails
|