rails_codebook 0.0.1.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +17 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +10 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/MIT-LICENSE +22 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/rails_codebook/application.js +16 -0
- data/app/assets/javascripts/rails_codebook/bootstrap.js +5 -0
- data/app/assets/javascripts/rails_codebook/codebooks.js +27 -0
- data/app/assets/javascripts/rails_codebook/jquery.autosize.js +192 -0
- data/app/assets/stylesheets/rails_codebook/application.css +13 -0
- data/app/assets/stylesheets/rails_codebook/bootstrap_and_overrides.css +7 -0
- data/app/assets/stylesheets/rails_codebook/codebooks.css +44 -0
- data/app/controllers/rails_codebook/admin/codebooks_controller.rb +65 -0
- data/app/controllers/rails_codebook/api/codebooks_controller.rb +44 -0
- data/app/helpers/rails_codebook/admin/codebooks_helper.rb +43 -0
- data/app/models/rails_codebook/codebook.rb +44 -0
- data/app/views/layouts/rails_codebook/application.html.erb +35 -0
- data/app/views/rails_codebook/admin/codebooks/_codebook.html.erb +44 -0
- data/app/views/rails_codebook/admin/codebooks/create.js.erb +9 -0
- data/app/views/rails_codebook/admin/codebooks/destroy.js.erb +2 -0
- data/app/views/rails_codebook/admin/codebooks/index.html.erb +90 -0
- data/config/initializers/will_paginate.rb +3 -0
- data/config/locales/cs.yml +268 -0
- data/config/locales/en.yml +11 -0
- data/config/routes.rb +25 -0
- data/lib/generators/rails_codebook/install/USAGE +9 -0
- data/lib/generators/rails_codebook/install/install_generator.rb +21 -0
- data/lib/generators/rails_codebook/install/templates/seeds.rb.erb +271 -0
- data/lib/rails_codebook/acts_as_codebook.rb +88 -0
- data/lib/rails_codebook/controller/base.rb +27 -0
- data/lib/rails_codebook/engine.rb +6 -0
- data/lib/rails_codebook/has_codebooks.rb +115 -0
- data/lib/rails_codebook/model/base.rb +73 -0
- data/lib/rails_codebook/version.rb +3 -0
- data/lib/rails_codebook.rb +50 -0
- data/rails_codebook.gemspec +40 -0
- data/script/rails +8 -0
- data/test/test_helper.rb +45 -0
- metadata +326 -0
@@ -0,0 +1,271 @@
|
|
1
|
+
unless RailsCodebook::Codebook.search(1, 'cb_name', 'boolean', true).length > 0
|
2
|
+
RailsCodebook::Codebook.create(value: 'yes', name: 'codebook.boolean.yes', cb_name: 'boolean')
|
3
|
+
RailsCodebook::Codebook.create(value: 'no', name: 'codebook.boolean.no', cb_name: 'boolean')
|
4
|
+
end
|
5
|
+
|
6
|
+
unless RailsCodebook::Codebook.search(1, 'cb_name', 'country', true).length > 0
|
7
|
+
RailsCodebook::Codebook.create(value: 'afg', name: 'codebook.country.afg', cb_name: 'country')
|
8
|
+
RailsCodebook::Codebook.create(value: 'ala', name: 'codebook.country.ala', cb_name: 'country')
|
9
|
+
RailsCodebook::Codebook.create(value: 'alb', name: 'codebook.country.alb', cb_name: 'country')
|
10
|
+
RailsCodebook::Codebook.create(value: 'dza', name: 'codebook.country.dza', cb_name: 'country')
|
11
|
+
RailsCodebook::Codebook.create(value: 'asm', name: 'codebook.country.asm', cb_name: 'country')
|
12
|
+
RailsCodebook::Codebook.create(value: 'vir', name: 'codebook.country.vir', cb_name: 'country')
|
13
|
+
RailsCodebook::Codebook.create(value: 'and', name: 'codebook.country.and', cb_name: 'country')
|
14
|
+
RailsCodebook::Codebook.create(value: 'ago', name: 'codebook.country.ago', cb_name: 'country')
|
15
|
+
RailsCodebook::Codebook.create(value: 'aia', name: 'codebook.country.aia', cb_name: 'country')
|
16
|
+
RailsCodebook::Codebook.create(value: 'ata', name: 'codebook.country.ata', cb_name: 'country')
|
17
|
+
RailsCodebook::Codebook.create(value: 'atg', name: 'codebook.country.atg', cb_name: 'country')
|
18
|
+
RailsCodebook::Codebook.create(value: 'arg', name: 'codebook.country.arg', cb_name: 'country')
|
19
|
+
RailsCodebook::Codebook.create(value: 'arm', name: 'codebook.country.arm', cb_name: 'country')
|
20
|
+
RailsCodebook::Codebook.create(value: 'abw', name: 'codebook.country.abw', cb_name: 'country')
|
21
|
+
RailsCodebook::Codebook.create(value: 'aus', name: 'codebook.country.aus', cb_name: 'country')
|
22
|
+
RailsCodebook::Codebook.create(value: 'aze', name: 'codebook.country.aze', cb_name: 'country')
|
23
|
+
RailsCodebook::Codebook.create(value: 'bhs', name: 'codebook.country.bhs', cb_name: 'country')
|
24
|
+
RailsCodebook::Codebook.create(value: 'bhr', name: 'codebook.country.bhr', cb_name: 'country')
|
25
|
+
RailsCodebook::Codebook.create(value: 'bgd', name: 'codebook.country.bgd', cb_name: 'country')
|
26
|
+
RailsCodebook::Codebook.create(value: 'brb', name: 'codebook.country.brb', cb_name: 'country')
|
27
|
+
RailsCodebook::Codebook.create(value: 'bel', name: 'codebook.country.bel', cb_name: 'country')
|
28
|
+
RailsCodebook::Codebook.create(value: 'blz', name: 'codebook.country.blz', cb_name: 'country')
|
29
|
+
RailsCodebook::Codebook.create(value: 'blr', name: 'codebook.country.blr', cb_name: 'country')
|
30
|
+
RailsCodebook::Codebook.create(value: 'ben', name: 'codebook.country.ben', cb_name: 'country')
|
31
|
+
RailsCodebook::Codebook.create(value: 'bmu', name: 'codebook.country.bmu', cb_name: 'country')
|
32
|
+
RailsCodebook::Codebook.create(value: 'btn', name: 'codebook.country.btn', cb_name: 'country')
|
33
|
+
RailsCodebook::Codebook.create(value: 'bol', name: 'codebook.country.bol', cb_name: 'country')
|
34
|
+
RailsCodebook::Codebook.create(value: 'bih', name: 'codebook.country.bih', cb_name: 'country')
|
35
|
+
RailsCodebook::Codebook.create(value: 'bwa', name: 'codebook.country.bwa', cb_name: 'country')
|
36
|
+
RailsCodebook::Codebook.create(value: 'bvt', name: 'codebook.country.bvt', cb_name: 'country')
|
37
|
+
RailsCodebook::Codebook.create(value: 'bra', name: 'codebook.country.bra', cb_name: 'country')
|
38
|
+
RailsCodebook::Codebook.create(value: 'iot', name: 'codebook.country.iot', cb_name: 'country')
|
39
|
+
RailsCodebook::Codebook.create(value: 'vgb', name: 'codebook.country.vgb', cb_name: 'country')
|
40
|
+
RailsCodebook::Codebook.create(value: 'brn', name: 'codebook.country.brn', cb_name: 'country')
|
41
|
+
RailsCodebook::Codebook.create(value: 'bgr', name: 'codebook.country.bgr', cb_name: 'country')
|
42
|
+
RailsCodebook::Codebook.create(value: 'bfa', name: 'codebook.country.bfa', cb_name: 'country')
|
43
|
+
RailsCodebook::Codebook.create(value: 'bdi', name: 'codebook.country.bdi', cb_name: 'country')
|
44
|
+
RailsCodebook::Codebook.create(value: 'cok', name: 'codebook.country.cok', cb_name: 'country')
|
45
|
+
RailsCodebook::Codebook.create(value: 'tcd', name: 'codebook.country.tcd', cb_name: 'country')
|
46
|
+
RailsCodebook::Codebook.create(value: 'mne', name: 'codebook.country.mne', cb_name: 'country')
|
47
|
+
RailsCodebook::Codebook.create(value: 'cze', name: 'codebook.country.cze', cb_name: 'country')
|
48
|
+
RailsCodebook::Codebook.create(value: 'chn', name: 'codebook.country.chn', cb_name: 'country')
|
49
|
+
RailsCodebook::Codebook.create(value: 'dnk', name: 'codebook.country.dnk', cb_name: 'country')
|
50
|
+
RailsCodebook::Codebook.create(value: 'cod', name: 'codebook.country.cod', cb_name: 'country')
|
51
|
+
RailsCodebook::Codebook.create(value: 'dma', name: 'codebook.country.dma', cb_name: 'country')
|
52
|
+
RailsCodebook::Codebook.create(value: 'dom', name: 'codebook.country.dom', cb_name: 'country')
|
53
|
+
RailsCodebook::Codebook.create(value: 'dji', name: 'codebook.country.dji', cb_name: 'country')
|
54
|
+
RailsCodebook::Codebook.create(value: 'egy', name: 'codebook.country.egy', cb_name: 'country')
|
55
|
+
RailsCodebook::Codebook.create(value: 'ecu', name: 'codebook.country.ecu', cb_name: 'country')
|
56
|
+
RailsCodebook::Codebook.create(value: 'eri', name: 'codebook.country.eri', cb_name: 'country')
|
57
|
+
RailsCodebook::Codebook.create(value: 'est', name: 'codebook.country.est', cb_name: 'country')
|
58
|
+
RailsCodebook::Codebook.create(value: 'eth', name: 'codebook.country.eth', cb_name: 'country')
|
59
|
+
RailsCodebook::Codebook.create(value: 'fro', name: 'codebook.country.fro', cb_name: 'country')
|
60
|
+
RailsCodebook::Codebook.create(value: 'flk', name: 'codebook.country.flk', cb_name: 'country')
|
61
|
+
RailsCodebook::Codebook.create(value: 'fji', name: 'codebook.country.fji', cb_name: 'country')
|
62
|
+
RailsCodebook::Codebook.create(value: 'phl', name: 'codebook.country.phl', cb_name: 'country')
|
63
|
+
RailsCodebook::Codebook.create(value: 'fin', name: 'codebook.country.fin', cb_name: 'country')
|
64
|
+
RailsCodebook::Codebook.create(value: 'fra', name: 'codebook.country.fra', cb_name: 'country')
|
65
|
+
RailsCodebook::Codebook.create(value: 'guf', name: 'codebook.country.guf', cb_name: 'country')
|
66
|
+
RailsCodebook::Codebook.create(value: 'atf', name: 'codebook.country.atf', cb_name: 'country')
|
67
|
+
RailsCodebook::Codebook.create(value: 'pyf', name: 'codebook.country.pyf', cb_name: 'country')
|
68
|
+
RailsCodebook::Codebook.create(value: 'gab', name: 'codebook.country.gab', cb_name: 'country')
|
69
|
+
RailsCodebook::Codebook.create(value: 'gmb', name: 'codebook.country.gmb', cb_name: 'country')
|
70
|
+
RailsCodebook::Codebook.create(value: 'gha', name: 'codebook.country.gha', cb_name: 'country')
|
71
|
+
RailsCodebook::Codebook.create(value: 'gib', name: 'codebook.country.gib', cb_name: 'country')
|
72
|
+
RailsCodebook::Codebook.create(value: 'grd', name: 'codebook.country.grd', cb_name: 'country')
|
73
|
+
RailsCodebook::Codebook.create(value: 'grl', name: 'codebook.country.grl', cb_name: 'country')
|
74
|
+
RailsCodebook::Codebook.create(value: 'geo', name: 'codebook.country.geo', cb_name: 'country')
|
75
|
+
RailsCodebook::Codebook.create(value: 'glp', name: 'codebook.country.glp', cb_name: 'country')
|
76
|
+
RailsCodebook::Codebook.create(value: 'gum', name: 'codebook.country.gum', cb_name: 'country')
|
77
|
+
RailsCodebook::Codebook.create(value: 'gtm', name: 'codebook.country.gtm', cb_name: 'country')
|
78
|
+
RailsCodebook::Codebook.create(value: 'gin', name: 'codebook.country.gin', cb_name: 'country')
|
79
|
+
RailsCodebook::Codebook.create(value: 'gnb', name: 'codebook.country.gnb', cb_name: 'country')
|
80
|
+
RailsCodebook::Codebook.create(value: 'ggy', name: 'codebook.country.ggy', cb_name: 'country')
|
81
|
+
RailsCodebook::Codebook.create(value: 'guy', name: 'codebook.country.guy', cb_name: 'country')
|
82
|
+
RailsCodebook::Codebook.create(value: 'hti', name: 'codebook.country.hti', cb_name: 'country')
|
83
|
+
RailsCodebook::Codebook.create(value: 'hmd', name: 'codebook.country.hmd', cb_name: 'country')
|
84
|
+
RailsCodebook::Codebook.create(value: 'hnd', name: 'codebook.country.hnd', cb_name: 'country')
|
85
|
+
RailsCodebook::Codebook.create(value: 'hkg', name: 'codebook.country.hkg', cb_name: 'country')
|
86
|
+
RailsCodebook::Codebook.create(value: 'chl', name: 'codebook.country.chl', cb_name: 'country')
|
87
|
+
RailsCodebook::Codebook.create(value: 'hrv', name: 'codebook.country.hrv', cb_name: 'country')
|
88
|
+
RailsCodebook::Codebook.create(value: 'ind', name: 'codebook.country.ind', cb_name: 'country')
|
89
|
+
RailsCodebook::Codebook.create(value: 'idn', name: 'codebook.country.idn', cb_name: 'country')
|
90
|
+
RailsCodebook::Codebook.create(value: 'irq', name: 'codebook.country.irq', cb_name: 'country')
|
91
|
+
RailsCodebook::Codebook.create(value: 'irn', name: 'codebook.country.irn', cb_name: 'country')
|
92
|
+
RailsCodebook::Codebook.create(value: 'irl', name: 'codebook.country.irl', cb_name: 'country')
|
93
|
+
RailsCodebook::Codebook.create(value: 'isl', name: 'codebook.country.isl', cb_name: 'country')
|
94
|
+
RailsCodebook::Codebook.create(value: 'ita', name: 'codebook.country.ita', cb_name: 'country')
|
95
|
+
RailsCodebook::Codebook.create(value: 'isr', name: 'codebook.country.isr', cb_name: 'country')
|
96
|
+
RailsCodebook::Codebook.create(value: 'jam', name: 'codebook.country.jam', cb_name: 'country')
|
97
|
+
RailsCodebook::Codebook.create(value: 'jpn', name: 'codebook.country.jpn', cb_name: 'country')
|
98
|
+
RailsCodebook::Codebook.create(value: 'yem', name: 'codebook.country.yem', cb_name: 'country')
|
99
|
+
RailsCodebook::Codebook.create(value: 'jey', name: 'codebook.country.jey', cb_name: 'country')
|
100
|
+
RailsCodebook::Codebook.create(value: 'zaf', name: 'codebook.country.zaf', cb_name: 'country')
|
101
|
+
RailsCodebook::Codebook.create(value: 'sgs', name: 'codebook.country.sgs', cb_name: 'country')
|
102
|
+
RailsCodebook::Codebook.create(value: 'kor', name: 'codebook.country.kor', cb_name: 'country')
|
103
|
+
RailsCodebook::Codebook.create(value: 'jor', name: 'codebook.country.jor', cb_name: 'country')
|
104
|
+
RailsCodebook::Codebook.create(value: 'cym', name: 'codebook.country.cym', cb_name: 'country')
|
105
|
+
RailsCodebook::Codebook.create(value: 'khm', name: 'codebook.country.khm', cb_name: 'country')
|
106
|
+
RailsCodebook::Codebook.create(value: 'cmr', name: 'codebook.country.cmr', cb_name: 'country')
|
107
|
+
RailsCodebook::Codebook.create(value: 'can', name: 'codebook.country.can', cb_name: 'country')
|
108
|
+
RailsCodebook::Codebook.create(value: 'cpv', name: 'codebook.country.cpv', cb_name: 'country')
|
109
|
+
RailsCodebook::Codebook.create(value: 'qat', name: 'codebook.country.qat', cb_name: 'country')
|
110
|
+
RailsCodebook::Codebook.create(value: 'kaz', name: 'codebook.country.kaz', cb_name: 'country')
|
111
|
+
RailsCodebook::Codebook.create(value: 'ken', name: 'codebook.country.ken', cb_name: 'country')
|
112
|
+
RailsCodebook::Codebook.create(value: 'kir', name: 'codebook.country.kir', cb_name: 'country')
|
113
|
+
RailsCodebook::Codebook.create(value: 'cck', name: 'codebook.country.cck', cb_name: 'country')
|
114
|
+
RailsCodebook::Codebook.create(value: 'col', name: 'codebook.country.col', cb_name: 'country')
|
115
|
+
RailsCodebook::Codebook.create(value: 'com', name: 'codebook.country.com', cb_name: 'country')
|
116
|
+
RailsCodebook::Codebook.create(value: 'cog', name: 'codebook.country.cog', cb_name: 'country')
|
117
|
+
RailsCodebook::Codebook.create(value: 'cri', name: 'codebook.country.cri', cb_name: 'country')
|
118
|
+
RailsCodebook::Codebook.create(value: 'cub', name: 'codebook.country.cub', cb_name: 'country')
|
119
|
+
RailsCodebook::Codebook.create(value: 'kwt', name: 'codebook.country.kwt', cb_name: 'country')
|
120
|
+
RailsCodebook::Codebook.create(value: 'cyp', name: 'codebook.country.cyp', cb_name: 'country')
|
121
|
+
RailsCodebook::Codebook.create(value: 'kgz', name: 'codebook.country.kgz', cb_name: 'country')
|
122
|
+
RailsCodebook::Codebook.create(value: 'lao', name: 'codebook.country.lao', cb_name: 'country')
|
123
|
+
RailsCodebook::Codebook.create(value: 'lso', name: 'codebook.country.lso', cb_name: 'country')
|
124
|
+
RailsCodebook::Codebook.create(value: 'lbn', name: 'codebook.country.lbn', cb_name: 'country')
|
125
|
+
RailsCodebook::Codebook.create(value: 'lbr', name: 'codebook.country.lbr', cb_name: 'country')
|
126
|
+
RailsCodebook::Codebook.create(value: 'lby', name: 'codebook.country.lby', cb_name: 'country')
|
127
|
+
RailsCodebook::Codebook.create(value: 'lie', name: 'codebook.country.lie', cb_name: 'country')
|
128
|
+
RailsCodebook::Codebook.create(value: 'ltu', name: 'codebook.country.ltu', cb_name: 'country')
|
129
|
+
RailsCodebook::Codebook.create(value: 'lva', name: 'codebook.country.lva', cb_name: 'country')
|
130
|
+
RailsCodebook::Codebook.create(value: 'lux', name: 'codebook.country.lux', cb_name: 'country')
|
131
|
+
RailsCodebook::Codebook.create(value: 'mac', name: 'codebook.country.mac', cb_name: 'country')
|
132
|
+
RailsCodebook::Codebook.create(value: 'mdg', name: 'codebook.country.mdg', cb_name: 'country')
|
133
|
+
RailsCodebook::Codebook.create(value: 'hun', name: 'codebook.country.hun', cb_name: 'country')
|
134
|
+
RailsCodebook::Codebook.create(value: 'mkd', name: 'codebook.country.mkd', cb_name: 'country')
|
135
|
+
RailsCodebook::Codebook.create(value: 'mys', name: 'codebook.country.mys', cb_name: 'country')
|
136
|
+
RailsCodebook::Codebook.create(value: 'mwi', name: 'codebook.country.mwi', cb_name: 'country')
|
137
|
+
RailsCodebook::Codebook.create(value: 'mdv', name: 'codebook.country.mdv', cb_name: 'country')
|
138
|
+
RailsCodebook::Codebook.create(value: 'mli', name: 'codebook.country.mli', cb_name: 'country')
|
139
|
+
RailsCodebook::Codebook.create(value: 'mlt', name: 'codebook.country.mlt', cb_name: 'country')
|
140
|
+
RailsCodebook::Codebook.create(value: 'imn', name: 'codebook.country.imn', cb_name: 'country')
|
141
|
+
RailsCodebook::Codebook.create(value: 'mar', name: 'codebook.country.mar', cb_name: 'country')
|
142
|
+
RailsCodebook::Codebook.create(value: 'mhl', name: 'codebook.country.mhl', cb_name: 'country')
|
143
|
+
RailsCodebook::Codebook.create(value: 'mtq', name: 'codebook.country.mtq', cb_name: 'country')
|
144
|
+
RailsCodebook::Codebook.create(value: 'mus', name: 'codebook.country.mus', cb_name: 'country')
|
145
|
+
RailsCodebook::Codebook.create(value: 'mrt', name: 'codebook.country.mrt', cb_name: 'country')
|
146
|
+
RailsCodebook::Codebook.create(value: 'myt', name: 'codebook.country.myt', cb_name: 'country')
|
147
|
+
RailsCodebook::Codebook.create(value: 'umi', name: 'codebook.country.umi', cb_name: 'country')
|
148
|
+
RailsCodebook::Codebook.create(value: 'mex', name: 'codebook.country.mex', cb_name: 'country')
|
149
|
+
RailsCodebook::Codebook.create(value: 'fsm', name: 'codebook.country.fsm', cb_name: 'country')
|
150
|
+
RailsCodebook::Codebook.create(value: 'mda', name: 'codebook.country.mda', cb_name: 'country')
|
151
|
+
RailsCodebook::Codebook.create(value: 'mco', name: 'codebook.country.mco', cb_name: 'country')
|
152
|
+
RailsCodebook::Codebook.create(value: 'mng', name: 'codebook.country.mng', cb_name: 'country')
|
153
|
+
RailsCodebook::Codebook.create(value: 'msr', name: 'codebook.country.msr', cb_name: 'country')
|
154
|
+
RailsCodebook::Codebook.create(value: 'moz', name: 'codebook.country.moz', cb_name: 'country')
|
155
|
+
RailsCodebook::Codebook.create(value: 'mmr', name: 'codebook.country.mmr', cb_name: 'country')
|
156
|
+
RailsCodebook::Codebook.create(value: 'nam', name: 'codebook.country.nam', cb_name: 'country')
|
157
|
+
RailsCodebook::Codebook.create(value: 'nru', name: 'codebook.country.nru', cb_name: 'country')
|
158
|
+
RailsCodebook::Codebook.create(value: 'deu', name: 'codebook.country.deu', cb_name: 'country')
|
159
|
+
RailsCodebook::Codebook.create(value: 'npl', name: 'codebook.country.npl', cb_name: 'country')
|
160
|
+
RailsCodebook::Codebook.create(value: 'ner', name: 'codebook.country.ner', cb_name: 'country')
|
161
|
+
RailsCodebook::Codebook.create(value: 'nga', name: 'codebook.country.nga', cb_name: 'country')
|
162
|
+
RailsCodebook::Codebook.create(value: 'nic', name: 'codebook.country.nic', cb_name: 'country')
|
163
|
+
RailsCodebook::Codebook.create(value: 'niu', name: 'codebook.country.niu', cb_name: 'country')
|
164
|
+
RailsCodebook::Codebook.create(value: 'ant', name: 'codebook.country.ant', cb_name: 'country')
|
165
|
+
RailsCodebook::Codebook.create(value: 'nld', name: 'codebook.country.nld', cb_name: 'country')
|
166
|
+
RailsCodebook::Codebook.create(value: 'nfk', name: 'codebook.country.nfk', cb_name: 'country')
|
167
|
+
RailsCodebook::Codebook.create(value: 'nor', name: 'codebook.country.nor', cb_name: 'country')
|
168
|
+
RailsCodebook::Codebook.create(value: 'ncl', name: 'codebook.country.ncl', cb_name: 'country')
|
169
|
+
RailsCodebook::Codebook.create(value: 'nzl', name: 'codebook.country.nzl', cb_name: 'country')
|
170
|
+
RailsCodebook::Codebook.create(value: 'omn', name: 'codebook.country.omn', cb_name: 'country')
|
171
|
+
RailsCodebook::Codebook.create(value: 'pak', name: 'codebook.country.pak', cb_name: 'country')
|
172
|
+
RailsCodebook::Codebook.create(value: 'plw', name: 'codebook.country.plw', cb_name: 'country')
|
173
|
+
RailsCodebook::Codebook.create(value: 'pse', name: 'codebook.country.pse', cb_name: 'country')
|
174
|
+
RailsCodebook::Codebook.create(value: 'pan', name: 'codebook.country.pan', cb_name: 'country')
|
175
|
+
RailsCodebook::Codebook.create(value: 'png', name: 'codebook.country.png', cb_name: 'country')
|
176
|
+
RailsCodebook::Codebook.create(value: 'pry', name: 'codebook.country.pry', cb_name: 'country')
|
177
|
+
RailsCodebook::Codebook.create(value: 'per', name: 'codebook.country.per', cb_name: 'country')
|
178
|
+
RailsCodebook::Codebook.create(value: 'pcn', name: 'codebook.country.pcn', cb_name: 'country')
|
179
|
+
RailsCodebook::Codebook.create(value: 'civ', name: 'codebook.country.civ', cb_name: 'country')
|
180
|
+
RailsCodebook::Codebook.create(value: 'pol', name: 'codebook.country.pol', cb_name: 'country')
|
181
|
+
RailsCodebook::Codebook.create(value: 'pri', name: 'codebook.country.pri', cb_name: 'country')
|
182
|
+
RailsCodebook::Codebook.create(value: 'prt', name: 'codebook.country.prt', cb_name: 'country')
|
183
|
+
RailsCodebook::Codebook.create(value: 'aut', name: 'codebook.country.aut', cb_name: 'country')
|
184
|
+
RailsCodebook::Codebook.create(value: 'gnq', name: 'codebook.country.gnq', cb_name: 'country')
|
185
|
+
RailsCodebook::Codebook.create(value: 'rou', name: 'codebook.country.rou', cb_name: 'country')
|
186
|
+
RailsCodebook::Codebook.create(value: 'rus', name: 'codebook.country.rus', cb_name: 'country')
|
187
|
+
RailsCodebook::Codebook.create(value: 'rwa', name: 'codebook.country.rwa', cb_name: 'country')
|
188
|
+
RailsCodebook::Codebook.create(value: 'grc', name: 'codebook.country.grc', cb_name: 'country')
|
189
|
+
RailsCodebook::Codebook.create(value: 'blm', name: 'codebook.country.blm', cb_name: 'country')
|
190
|
+
RailsCodebook::Codebook.create(value: 'maf', name: 'codebook.country.maf', cb_name: 'country')
|
191
|
+
RailsCodebook::Codebook.create(value: 'spm', name: 'codebook.country.spm', cb_name: 'country')
|
192
|
+
RailsCodebook::Codebook.create(value: 'slv', name: 'codebook.country.slv', cb_name: 'country')
|
193
|
+
RailsCodebook::Codebook.create(value: 'wsm', name: 'codebook.country.wsm', cb_name: 'country')
|
194
|
+
RailsCodebook::Codebook.create(value: 'smr', name: 'codebook.country.smr', cb_name: 'country')
|
195
|
+
RailsCodebook::Codebook.create(value: 'sau', name: 'codebook.country.sau', cb_name: 'country')
|
196
|
+
RailsCodebook::Codebook.create(value: 'sen', name: 'codebook.country.sen', cb_name: 'country')
|
197
|
+
RailsCodebook::Codebook.create(value: 'prk', name: 'codebook.country.prk', cb_name: 'country')
|
198
|
+
RailsCodebook::Codebook.create(value: 'mnp', name: 'codebook.country.mnp', cb_name: 'country')
|
199
|
+
RailsCodebook::Codebook.create(value: 'syc', name: 'codebook.country.syc', cb_name: 'country')
|
200
|
+
RailsCodebook::Codebook.create(value: 'sle', name: 'codebook.country.sle', cb_name: 'country')
|
201
|
+
RailsCodebook::Codebook.create(value: 'sgp', name: 'codebook.country.sgp', cb_name: 'country')
|
202
|
+
RailsCodebook::Codebook.create(value: 'svk', name: 'codebook.country.svk', cb_name: 'country')
|
203
|
+
RailsCodebook::Codebook.create(value: 'svn', name: 'codebook.country.svn', cb_name: 'country')
|
204
|
+
RailsCodebook::Codebook.create(value: 'som', name: 'codebook.country.som', cb_name: 'country')
|
205
|
+
RailsCodebook::Codebook.create(value: 'are', name: 'codebook.country.are', cb_name: 'country')
|
206
|
+
RailsCodebook::Codebook.create(value: 'gbr', name: 'codebook.country.gbr', cb_name: 'country')
|
207
|
+
RailsCodebook::Codebook.create(value: 'usa', name: 'codebook.country.usa', cb_name: 'country')
|
208
|
+
RailsCodebook::Codebook.create(value: 'srb', name: 'codebook.country.srb', cb_name: 'country')
|
209
|
+
RailsCodebook::Codebook.create(value: 'caf', name: 'codebook.country.caf', cb_name: 'country')
|
210
|
+
RailsCodebook::Codebook.create(value: 'sdn', name: 'codebook.country.sdn', cb_name: 'country')
|
211
|
+
RailsCodebook::Codebook.create(value: 'sur', name: 'codebook.country.sur', cb_name: 'country')
|
212
|
+
RailsCodebook::Codebook.create(value: 'shn', name: 'codebook.country.shn', cb_name: 'country')
|
213
|
+
RailsCodebook::Codebook.create(value: 'lca', name: 'codebook.country.lca', cb_name: 'country')
|
214
|
+
RailsCodebook::Codebook.create(value: 'kna', name: 'codebook.country.kna', cb_name: 'country')
|
215
|
+
RailsCodebook::Codebook.create(value: 'stp', name: 'codebook.country.stp', cb_name: 'country')
|
216
|
+
RailsCodebook::Codebook.create(value: 'vct', name: 'codebook.country.vct', cb_name: 'country')
|
217
|
+
RailsCodebook::Codebook.create(value: 'swz', name: 'codebook.country.swz', cb_name: 'country')
|
218
|
+
RailsCodebook::Codebook.create(value: 'syr', name: 'codebook.country.syr', cb_name: 'country')
|
219
|
+
RailsCodebook::Codebook.create(value: 'slb', name: 'codebook.country.slb', cb_name: 'country')
|
220
|
+
RailsCodebook::Codebook.create(value: 'esp', name: 'codebook.country.esp', cb_name: 'country')
|
221
|
+
RailsCodebook::Codebook.create(value: 'sjm', name: 'codebook.country.sjm', cb_name: 'country')
|
222
|
+
RailsCodebook::Codebook.create(value: 'lka', name: 'codebook.country.lka', cb_name: 'country')
|
223
|
+
RailsCodebook::Codebook.create(value: 'swe', name: 'codebook.country.swe', cb_name: 'country')
|
224
|
+
RailsCodebook::Codebook.create(value: 'che', name: 'codebook.country.che', cb_name: 'country')
|
225
|
+
RailsCodebook::Codebook.create(value: 'tjk', name: 'codebook.country.tjk', cb_name: 'country')
|
226
|
+
RailsCodebook::Codebook.create(value: 'tza', name: 'codebook.country.tza', cb_name: 'country')
|
227
|
+
RailsCodebook::Codebook.create(value: 'tha', name: 'codebook.country.tha', cb_name: 'country')
|
228
|
+
RailsCodebook::Codebook.create(value: 'twn', name: 'codebook.country.twn', cb_name: 'country')
|
229
|
+
RailsCodebook::Codebook.create(value: 'tgo', name: 'codebook.country.tgo', cb_name: 'country')
|
230
|
+
RailsCodebook::Codebook.create(value: 'tkl', name: 'codebook.country.tkl', cb_name: 'country')
|
231
|
+
RailsCodebook::Codebook.create(value: 'ton', name: 'codebook.country.ton', cb_name: 'country')
|
232
|
+
RailsCodebook::Codebook.create(value: 'tto', name: 'codebook.country.tto', cb_name: 'country')
|
233
|
+
RailsCodebook::Codebook.create(value: 'tun', name: 'codebook.country.tun', cb_name: 'country')
|
234
|
+
RailsCodebook::Codebook.create(value: 'tur', name: 'codebook.country.tur', cb_name: 'country')
|
235
|
+
RailsCodebook::Codebook.create(value: 'tkm', name: 'codebook.country.tkm', cb_name: 'country')
|
236
|
+
RailsCodebook::Codebook.create(value: 'tca', name: 'codebook.country.tca', cb_name: 'country')
|
237
|
+
RailsCodebook::Codebook.create(value: 'tuv', name: 'codebook.country.tuv', cb_name: 'country')
|
238
|
+
RailsCodebook::Codebook.create(value: 'uga', name: 'codebook.country.uga', cb_name: 'country')
|
239
|
+
RailsCodebook::Codebook.create(value: 'ukr', name: 'codebook.country.ukr', cb_name: 'country')
|
240
|
+
RailsCodebook::Codebook.create(value: 'ury', name: 'codebook.country.ury', cb_name: 'country')
|
241
|
+
RailsCodebook::Codebook.create(value: 'uzb', name: 'codebook.country.uzb', cb_name: 'country')
|
242
|
+
RailsCodebook::Codebook.create(value: 'cxr', name: 'codebook.country.cxr', cb_name: 'country')
|
243
|
+
RailsCodebook::Codebook.create(value: 'vut', name: 'codebook.country.vut', cb_name: 'country')
|
244
|
+
RailsCodebook::Codebook.create(value: 'vat', name: 'codebook.country.vat', cb_name: 'country')
|
245
|
+
RailsCodebook::Codebook.create(value: 'ven', name: 'codebook.country.ven', cb_name: 'country')
|
246
|
+
RailsCodebook::Codebook.create(value: 'vnm', name: 'codebook.country.vnm', cb_name: 'country')
|
247
|
+
RailsCodebook::Codebook.create(value: 'tls', name: 'codebook.country.tls', cb_name: 'country')
|
248
|
+
RailsCodebook::Codebook.create(value: 'wlf', name: 'codebook.country.wlf', cb_name: 'country')
|
249
|
+
RailsCodebook::Codebook.create(value: 'zmb', name: 'codebook.country.zmb', cb_name: 'country')
|
250
|
+
RailsCodebook::Codebook.create(value: 'esh', name: 'codebook.country.esh', cb_name: 'country')
|
251
|
+
RailsCodebook::Codebook.create(value: 'zwe', name: 'codebook.country.zwe', cb_name: 'country')
|
252
|
+
RailsCodebook::Codebook.create(value: 'svk', name: 'codebook.country.svk', cb_name: 'country')
|
253
|
+
end
|
254
|
+
|
255
|
+
unless RailsCodebook::Codebook.search(1, 'cb_name', 'currency', true).length > 0
|
256
|
+
RailsCodebook::Codebook.create(value: 'aud', name: 'codebook.currency.aud', cb_name: 'currency')
|
257
|
+
RailsCodebook::Codebook.create(value: 'cad', name: 'codebook.currency.cad', cb_name: 'currency')
|
258
|
+
RailsCodebook::Codebook.create(value: 'chf', name: 'codebook.currency.chf', cb_name: 'currency')
|
259
|
+
RailsCodebook::Codebook.create(value: 'czk', name: 'codebook.currency.czk', cb_name: 'currency')
|
260
|
+
RailsCodebook::Codebook.create(value: 'eur', name: 'codebook.currency.eur', cb_name: 'currency')
|
261
|
+
RailsCodebook::Codebook.create(value: 'gbp', name: 'codebook.currency.gbp', cb_name: 'currency')
|
262
|
+
RailsCodebook::Codebook.create(value: 'jpy', name: 'codebook.currency.jpy', cb_name: 'currency')
|
263
|
+
RailsCodebook::Codebook.create(value: 'rub', name: 'codebook.currency.rub', cb_name: 'currency')
|
264
|
+
RailsCodebook::Codebook.create(value: 'usd', name: 'codebook.currency.usd', cb_name: 'currency')
|
265
|
+
end
|
266
|
+
|
267
|
+
unless RailsCodebook::Codebook.search(1, 'cb_name', 'importance', true).length > 0
|
268
|
+
RailsCodebook::Codebook.create(value: 'low', name: 'codebook.importance.low', cb_name: 'importance')
|
269
|
+
RailsCodebook::Codebook.create(value: 'medium', name: 'codebook.importance.medium', cb_name: 'importance')
|
270
|
+
RailsCodebook::Codebook.create(value: 'high', name: 'codebook.importance.high', cb_name: 'importance')
|
271
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
class << ActiveRecord::Base
|
2
|
+
|
3
|
+
# defining simple rules for codebook method generation
|
4
|
+
# class Project < ActiveRecord::Base
|
5
|
+
# acts_as_codebook({
|
6
|
+
# "method" => "method_base_name", // base name to which suffixes will be added
|
7
|
+
# // otherwise model_name will be used
|
8
|
+
# "value" => "clo_name_for_value",
|
9
|
+
# "key" => "clo_name_for_key"
|
10
|
+
# })
|
11
|
+
# end
|
12
|
+
def acts_as_codebook params={}, options={}
|
13
|
+
|
14
|
+
##
|
15
|
+
#
|
16
|
+
# self _values [a,b,c]
|
17
|
+
# self _keys [1,2,3]
|
18
|
+
# self _all {{cb},{cb},{cb}}
|
19
|
+
# _object Object
|
20
|
+
# _object_all [Object,Object]
|
21
|
+
# _this {cb}
|
22
|
+
# _name "cb_name"
|
23
|
+
#
|
24
|
+
##
|
25
|
+
|
26
|
+
# default options
|
27
|
+
options = {
|
28
|
+
"method" => (self.model_name.to_s.downcase+"_cb").to_s,
|
29
|
+
"key" => "id",
|
30
|
+
"value" => "name"
|
31
|
+
}
|
32
|
+
|
33
|
+
# merge default params with given ones (given are beating those default of course)
|
34
|
+
options = options.merge params
|
35
|
+
|
36
|
+
define_method (options["method"]+"_object").to_sym do
|
37
|
+
self.class.where(["id=?", self.id]).select("#{options["key"]}, #{options["value"]}")
|
38
|
+
end
|
39
|
+
|
40
|
+
define_method (options["method"]+"_this").to_sym do
|
41
|
+
self.class.find(self.id).codebookify
|
42
|
+
end
|
43
|
+
|
44
|
+
define_singleton_method (options["method"]+"_object_all").to_sym do
|
45
|
+
cb_model.all.select("#{options["key"]}, #{options["value"]}")
|
46
|
+
end
|
47
|
+
|
48
|
+
# just giving back the codebook name you chose or default
|
49
|
+
define_singleton_method (options["method"]+"_name").to_sym do
|
50
|
+
options["method"]
|
51
|
+
end
|
52
|
+
|
53
|
+
# getting of the array of
|
54
|
+
define_singleton_method (options["method"]+"_keys").to_sym do |array=[]|
|
55
|
+
cb_model.all.each {|row| array << row.send(options["key"])}; array
|
56
|
+
end
|
57
|
+
|
58
|
+
define_singleton_method (options["method"]+"_values").to_sym do |array=[]|
|
59
|
+
cb_model.all.each {|row| array << row.send(options["value"])}; array
|
60
|
+
end
|
61
|
+
|
62
|
+
define_singleton_method (options["method"]+"_all").to_sym do |array=[]|
|
63
|
+
cb_model.all.each {|row| array << row.codebookify}; array
|
64
|
+
end
|
65
|
+
|
66
|
+
# will there ever be other formats ?
|
67
|
+
define_method :codebookify do |format=:cb_format|
|
68
|
+
self.send(format)
|
69
|
+
end
|
70
|
+
|
71
|
+
# default cb format -> JSON
|
72
|
+
define_method :cb_format do
|
73
|
+
{
|
74
|
+
key: self.send(options["key"]),
|
75
|
+
value: self.send(options["value"])
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def cb_model
|
82
|
+
self.model_name.to_s.constantize
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RailsCodebook
|
2
|
+
|
3
|
+
module Controller
|
4
|
+
|
5
|
+
class Base < ActionController::Base
|
6
|
+
helper :all
|
7
|
+
before_filter :set_locale
|
8
|
+
|
9
|
+
# setting locale if found in url
|
10
|
+
def set_locale
|
11
|
+
I18n.locale = params[:lang] || I18n.default_locale
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# name of codebook model, still the same for now...
|
17
|
+
def codebook
|
18
|
+
"RailsCodebook::#{controller_name.classify}".constantize
|
19
|
+
end
|
20
|
+
|
21
|
+
def codebook_params
|
22
|
+
params.require(controller_name.singularize.to_sym).permit(:name, :value, :cb_name, :sequence, :deleted, :updated_at, :created_at)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
class << ActiveRecord::Base
|
2
|
+
|
3
|
+
# defining simple rules for codebook method generation
|
4
|
+
# class Project < ActiveRecord::Base
|
5
|
+
# has_codebooks({
|
6
|
+
# "status_cb" => "boolean", // defining column_name => codebook_name
|
7
|
+
# "importance_cb" => "importance",
|
8
|
+
# "options" => {
|
9
|
+
# "status_cb" => {
|
10
|
+
# "fk_cb" => "id" // which value from codebook to use as FK for the model (usually id, value)
|
11
|
+
# // can also be defined for each one codebook :)
|
12
|
+
# }
|
13
|
+
# "fk_cb" => "value" // all other will use this fallback or the default _value one :)
|
14
|
+
# }
|
15
|
+
# })
|
16
|
+
# end
|
17
|
+
def has_codebooks params={}, options={}
|
18
|
+
|
19
|
+
# options given in model definition
|
20
|
+
# "cb_format" => manually defined how to find codebook
|
21
|
+
# e.x. => polymorphic tables having role_cb row, but every time ...able_types is codebook, like this:
|
22
|
+
# class ProjectRelations < ActiveRecord::Base
|
23
|
+
# has_codebooks({
|
24
|
+
# "role_cb" => "polymorphic" // says look to options, you are not going to find cb_name here :)
|
25
|
+
# "options" => {
|
26
|
+
# "role_cb" => { // in casse there are more codebooks that need these options
|
27
|
+
# "cb_format" => "projectable_type" // will always be joined from cb_format+"_"+model.table_name+"_"+column_name.pluralized
|
28
|
+
# }
|
29
|
+
# }
|
30
|
+
# })
|
31
|
+
# end
|
32
|
+
|
33
|
+
# default value, if not entered
|
34
|
+
options["fk_cb"] = "value"
|
35
|
+
|
36
|
+
if params.include? "options"
|
37
|
+
options = params["options"]
|
38
|
+
params.delete("options")
|
39
|
+
options["fk_cb"] = options["fk_cb"] if options.include? "fk_cb"
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
#
|
44
|
+
# self _values [a,b,c]
|
45
|
+
# self _keys [1,2,3]
|
46
|
+
# self _all {{cb},{cb},{cb}}
|
47
|
+
# "" {json}
|
48
|
+
# _collection {{cb},{cb}}
|
49
|
+
# _object Object
|
50
|
+
# _object_all [Object,Object]
|
51
|
+
# _this {cb}
|
52
|
+
# _codebook_name "cb_name"
|
53
|
+
#
|
54
|
+
##
|
55
|
+
|
56
|
+
params.each do |column_name, codebook_name|
|
57
|
+
|
58
|
+
# get the options just for the one codebook
|
59
|
+
cb_options = (options.include?("#{column_name}")) ? options["#{column_name}"] : []
|
60
|
+
fk_cb = options["fk_cb"]
|
61
|
+
|
62
|
+
base_method_name = column_name.gsub("_cb", "")
|
63
|
+
|
64
|
+
unless cb_options.empty?
|
65
|
+
codebook_name = cb_options["cb_format"]+"_"+self.table_name.singularize+"_"+base_method_name.pluralize if codebook_name == "polymorphic"
|
66
|
+
fk_cb = cb_options["fk_cb"]
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
# method for getting the one row referenced from model as object (something_object)
|
71
|
+
define_method (base_method_name+"_object").to_sym do |hash={}|
|
72
|
+
all = RailsCodebook::Codebook.search(params[:page], "cb_name", codebook_name, true)
|
73
|
+
all.each {|row| return row if row.send(fk_cb) == self.send(column_name) }; hash
|
74
|
+
end
|
75
|
+
|
76
|
+
# method for getting the one row referenced from model as json (something)
|
77
|
+
define_method (base_method_name+"_codebook_name").to_sym do
|
78
|
+
codebook_name
|
79
|
+
end
|
80
|
+
|
81
|
+
# method for getting the one row referenced from model as json (something)
|
82
|
+
define_method base_method_name.to_sym do
|
83
|
+
self.send(base_method_name+"_object").cb_serialize
|
84
|
+
end
|
85
|
+
|
86
|
+
# method for getting all possible values of codebook or the column given (something_object_all) => OBJECT
|
87
|
+
define_singleton_method (base_method_name+"_object_all").to_sym do
|
88
|
+
RailsCodebook::Codebook.search(params[:page], "cb_name", codebook_name, true)
|
89
|
+
end
|
90
|
+
|
91
|
+
# method for getting all possible values of codebook or the column given (something_object_all) => OBJECT
|
92
|
+
define_singleton_method (base_method_name+"_collection").to_sym do
|
93
|
+
RailsCodebook::Codebook.search(params[:page], "cb_name", codebook_name, true).cb_serialize("collection_#{fk_cb}".to_sym)
|
94
|
+
end
|
95
|
+
|
96
|
+
# method for getting all possible values of codebook or the column given (something_all) => JSON
|
97
|
+
define_singleton_method (base_method_name+"_all").to_sym do
|
98
|
+
RailsCodebook::Codebook.search(params[:page], "cb_name", codebook_name, true).cb_serialize
|
99
|
+
end
|
100
|
+
|
101
|
+
# method for getting the array of i18ned names of cb rows (something_names)
|
102
|
+
define_singleton_method (base_method_name+"_values").to_sym do |array=[]|
|
103
|
+
RailsCodebook::Codebook.search(params[:page], "cb_name", codebook_name, true).each {|cb| array << I18n.t(cb.name) }; array
|
104
|
+
end
|
105
|
+
|
106
|
+
# method for getting the array of values of cb rows (something_values)
|
107
|
+
define_singleton_method (base_method_name+"_keys").to_sym do
|
108
|
+
RailsCodebook::Codebook.search(params[:page], "cb_name", codebook_name, true).map(&:value)
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module RailsCodebook
|
2
|
+
|
3
|
+
module Model
|
4
|
+
|
5
|
+
class Base < ::RedisOrm::Base
|
6
|
+
self.abstract_class = true
|
7
|
+
|
8
|
+
# array with value columns from the codebook
|
9
|
+
def self.get_values
|
10
|
+
self.all.map(&:value)
|
11
|
+
end
|
12
|
+
|
13
|
+
# array with name columns from the codebook
|
14
|
+
def self.get_names
|
15
|
+
self.all.map(&:name)
|
16
|
+
end
|
17
|
+
|
18
|
+
# searching through codebook with usage of i18n
|
19
|
+
def self.search_i18n query_string, array=[]
|
20
|
+
self.all.each {|redis_row| array << redis_row.codebook_format if I18n.t(redis_row.name) =~ /#{query_string}/i }; array
|
21
|
+
end
|
22
|
+
|
23
|
+
# universal regexp_search
|
24
|
+
def self.search page=1, column_name='', value='', strict=false, init_cb=RailsCodebook::Codebook.all
|
25
|
+
if column_name != ''
|
26
|
+
strict ? \
|
27
|
+
init_cb.select{|j| ((column_name == 'name') ? I18n.t(j.send(column_name)) : j.send(column_name)) =~ /^#{value}$/i}.paginate(page: page) : \
|
28
|
+
init_cb.select{|j| ((column_name == 'name') ? I18n.t(j.send(column_name)) : j.send(column_name)) =~ /#{value}/i}.paginate(page: page)
|
29
|
+
else
|
30
|
+
init_cb.paginate(page: page)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def cb_serialize format=:codebook_format
|
35
|
+
format = :codebook_format if format.nil?
|
36
|
+
self.send(format)
|
37
|
+
end
|
38
|
+
|
39
|
+
def codebook_format
|
40
|
+
{
|
41
|
+
id: self.id,
|
42
|
+
value: self.value,
|
43
|
+
name: I18n.t(self.name),
|
44
|
+
cb_name: self.cb_name,
|
45
|
+
created_at: self.created_at,
|
46
|
+
updated_at: self.updated_at,
|
47
|
+
sequence: self.sequence,
|
48
|
+
deleted: self.deleted
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
# possible formats for collection (selectbox style) :
|
53
|
+
# collection_id
|
54
|
+
# collection_value
|
55
|
+
# I dont see why anyone would use other.... :)
|
56
|
+
['id','value'].each do |attrib|
|
57
|
+
define_method "collection_#{attrib}".to_sym do
|
58
|
+
{
|
59
|
+
"#{attrib}".to_sym => self.send(attrib),
|
60
|
+
:name => I18n.t(self.name)
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def to_partial_path
|
66
|
+
"codebooks/codebook"
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "redis"
|
2
|
+
require 'twitter-bootstrap-rails'
|
3
|
+
require 'jquery-rails'
|
4
|
+
require 'jquery-ui-rails'
|
5
|
+
require 'will_paginate'
|
6
|
+
|
7
|
+
require "rails_codebook/version"
|
8
|
+
require "rails_codebook/engine"
|
9
|
+
require "rails_codebook/has_codebooks"
|
10
|
+
require "rails_codebook/acts_as_codebook"
|
11
|
+
|
12
|
+
require "rails_codebook/model/base"
|
13
|
+
require "rails_codebook/controller/base"
|
14
|
+
|
15
|
+
|
16
|
+
module RailsCodebook
|
17
|
+
extend self
|
18
|
+
|
19
|
+
attr_accessor :redis
|
20
|
+
@@redis = Redis.new
|
21
|
+
|
22
|
+
def self.redis=(redis)
|
23
|
+
@@redis = redis
|
24
|
+
RedisOrm.redis = redis
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.redis
|
28
|
+
@@redis
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Array
|
33
|
+
def cb_serialize format=:codebook_format, array=[]
|
34
|
+
self.each { |row| array << row.cb_serialize(format) }; array
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Hash
|
39
|
+
def cb_serialize format=:codebook_format, array=[]
|
40
|
+
self.each { |row| array << row.cb_serialize(format) }; array
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class NilClass
|
45
|
+
def cb_serialize format=:codebook_format
|
46
|
+
return {
|
47
|
+
content: []
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|