searcher_generator 1.0.0 → 1.0.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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d1971844b1e1f18766081f200b3854d0ac7e2f1f
|
|
4
|
+
data.tar.gz: 6737e5364750fc2bc4f8fdc4c97f236a047ce036
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c7892a58f78cd4e31c760bad7e14ef671562b9c7452392bf26684503390d7a31bbf0ecf943f77c6527d613f241b7bf0a73e2b18c92c3079ccc444a74083642e8
|
|
7
|
+
data.tar.gz: 010dee42c38af8ff97fa50ac11275dee0205e6187108dc8bbd0e5d8fca7c6aa723a2c45ac4a7435d7e1fb5a8c1488c76f34d7acf1b57bc58ea74c7d250d816ff
|
data/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Or install it yourself as:
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
rails generate search <ModelName> atrribute:"attribute humanize name"
|
|
21
|
+
rails generate search <ModelName> atrribute:"attribute humanize name" humanize_model@:<model humanize name>
|
|
22
22
|
|
|
23
23
|
This will create:
|
|
24
24
|
1- searcher class '<ModelSearcher>'
|
|
@@ -33,6 +33,7 @@ Or install it yourself as:
|
|
|
33
33
|
(iii) e$ - it will create enum type attribute
|
|
34
34
|
(iv) approval_status@ - it will create approval_status attribute
|
|
35
35
|
(v) page@ - it will create page attribute
|
|
36
|
+
(vi) humanize_model@ - it will add humanize model name
|
|
36
37
|
|
|
37
38
|
Things to do after running this command
|
|
38
39
|
1- changes in routes file
|
|
@@ -45,7 +45,8 @@ class SearchGenerator < Rails::Generators::Base
|
|
|
45
45
|
def symbolize_attribute
|
|
46
46
|
f = ""
|
|
47
47
|
get_attributes.each do |k, v|
|
|
48
|
-
if k.include?("
|
|
48
|
+
if k.include?("humanize_model@")
|
|
49
|
+
elsif k.include?("bet1")
|
|
49
50
|
k = k.chomp("bet1")
|
|
50
51
|
f = f + ":from_#{k}, "
|
|
51
52
|
f = f + ":to_#{k}, "
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
= search_form_for @searcher do |f|
|
|
2
2
|
= f.standard_fields
|
|
3
3
|
<% attributes.each do |attr|-%>
|
|
4
|
-
<% if attr[0].include?("approval_status@") or attr[0].include?("page@")-%>
|
|
4
|
+
<% if attr[0].include?("approval_status@") or attr[0].include?("page@") or attr[0].include?("humanize_model@")-%>
|
|
5
5
|
<% elsif attr[0].include?("e$") -%>
|
|
6
6
|
= f.input :<%=attr[0].chomp('e$')%>, as: :enum
|
|
7
7
|
<% elsif attr[0].include?("bet1") -%>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
en:
|
|
2
2
|
activerecord:
|
|
3
3
|
models:
|
|
4
|
-
<%= model_name.underscore %>: "<%=
|
|
4
|
+
<%= model_name.underscore %>: "<%=get_attributes["humanize_model@"]%>"
|
|
5
5
|
attributes:
|
|
6
6
|
<%= model_name.underscore %>: &attributes
|
|
7
7
|
<% get_attributes.each do |attr| -%>
|
|
8
|
-
<% if attr[0].include?("approval_status@") or attr[0].include?("page@")-%>
|
|
8
|
+
<% if attr[0].include?("approval_status@") or attr[0].include?("page@")or attr[0].include?("humanize_model@")-%>
|
|
9
9
|
<% elsif attr[0].include?("e$") -%>
|
|
10
10
|
<%=attr[0].chomp('e$')%>: "<%= attr[1]%>"
|
|
11
11
|
<% elsif attr[0].include?("bet1") -%>
|
|
@@ -16,7 +16,7 @@ en:
|
|
|
16
16
|
<% end -%>
|
|
17
17
|
activemodel:
|
|
18
18
|
models:
|
|
19
|
-
<%= model_name.underscore %>_searcher: '<%=
|
|
19
|
+
<%= model_name.underscore %>_searcher: '<%=get_attributes["humanize_model@"]%>'
|
|
20
20
|
attributes:
|
|
21
21
|
<%= model_name.underscore %>_searcher:
|
|
22
22
|
<<: *attributes
|