abyme 0.5.0 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.babelrc +6 -0
- data/CHANGELOG.md +22 -1
- data/Gemfile.lock +91 -84
- data/README.md +58 -22
- data/abyme.gemspec +4 -2
- data/dist/abyme.js +2 -0
- data/dist/abyme.js.map +1 -0
- data/dist/abyme.modern.js +2 -0
- data/dist/abyme.modern.js.map +1 -0
- data/dist/abyme.module.js +2 -0
- data/dist/abyme.module.js.map +1 -0
- data/dist/abyme.umd.js +2 -0
- data/dist/abyme.umd.js.map +1 -0
- data/jest/jest-setup.js +2 -0
- data/lib/abyme/abyme_builder.rb +6 -8
- data/lib/abyme/action_view_extensions/builder.rb +2 -0
- data/lib/abyme/model.rb +17 -15
- data/lib/abyme/version.rb +2 -2
- data/lib/abyme/view_helpers.rb +55 -48
- data/lib/generators/abyme/controller/USAGE +16 -0
- data/lib/generators/abyme/controller/controller_generator.rb +25 -0
- data/lib/generators/abyme/model/USAGE +21 -0
- data/lib/generators/abyme/model/model_generator.rb +70 -0
- data/lib/generators/abyme/resource/USAGE +10 -0
- data/lib/generators/abyme/resource/resource_generator.rb +18 -0
- data/lib/generators/abyme/stimulus/USAGE +5 -0
- data/lib/generators/abyme/stimulus/stimulus_generator.rb +21 -0
- data/lib/generators/abyme/view/USAGE +11 -0
- data/lib/generators/abyme/view/view_generator.rb +65 -0
- data/package-lock.json +31992 -0
- data/package.json +34 -4
- data/specs/index.test.js +26 -0
- data/{javascript → src}/abyme_controller.js +1 -3
- data/{javascript → src}/index.js +0 -0
- data/yarn.lock +7678 -22
- metadata +55 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e71aaa0391ddf79198fbd0e3076b7899ecd8a72abbfac41429d416f3a671dccc
|
4
|
+
data.tar.gz: 382947241368e89f93142bb5b0c9b34f1af8323f5d8689fd54d2dd4a7907385e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34cc3af27975485027977aa98f51419924ec4d42f3f72a0a03c559eaed18bb2a2e5734efc9345ed10631740f7860b63691e42da159c84e89e27711505ce19a6c
|
7
|
+
data.tar.gz: e9588871ddce9c79d34d77511a9f56f29a280177a5dc9f9fe056cc7540ce2e28d3b0a64d6ceb5735811cd910e9cf1692e4a5ff81a87eaec8d0a0c4d466ff216d
|
data/.DS_Store
CHANGED
Binary file
|
data/.babelrc
ADDED
data/CHANGELOG.md
CHANGED
@@ -2,11 +2,32 @@
|
|
2
2
|
|
3
3
|
## [Unreleased](https://github.com/bear-in-mind/abyme/tree/HEAD)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.
|
5
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.5.0...HEAD)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- retro compatibility with former public method names [\#26](https://github.com/bear-in-mind/abyme/pull/26) ([bear-in-mind](https://github.com/bear-in-mind))
|
10
|
+
|
11
|
+
## [v0.5.0](https://github.com/bear-in-mind/abyme/tree/v0.5.0) (2021-02-26)
|
12
|
+
|
13
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.2.5...v0.5.0)
|
14
|
+
|
15
|
+
**Merged pull requests:**
|
16
|
+
|
17
|
+
- Dynamic strong params for nested attributes [\#23](https://github.com/bear-in-mind/abyme/pull/23) ([bear-in-mind](https://github.com/bear-in-mind))
|
18
|
+
|
19
|
+
## [v0.2.5](https://github.com/bear-in-mind/abyme/tree/v0.2.5) (2021-02-12)
|
20
|
+
|
21
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.4.0...v0.2.5)
|
22
|
+
|
23
|
+
## [v0.4.0](https://github.com/bear-in-mind/abyme/tree/v0.4.0) (2021-02-12)
|
24
|
+
|
25
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.2.4...v0.4.0)
|
6
26
|
|
7
27
|
**Merged pull requests:**
|
8
28
|
|
9
29
|
- Bump nokogiri from 1.10.10 to 1.11.1 [\#22](https://github.com/bear-in-mind/abyme/pull/22) ([dependabot[bot]](https://github.com/apps/dependabot))
|
30
|
+
- Methods naming change & FormBuilder extension [\#21](https://github.com/bear-in-mind/abyme/pull/21) ([bear-in-mind](https://github.com/bear-in-mind))
|
10
31
|
- Solved JS compile bug [\#19](https://github.com/bear-in-mind/abyme/pull/19) ([bear-in-mind](https://github.com/bear-in-mind))
|
11
32
|
|
12
33
|
## [v0.2.4](https://github.com/bear-in-mind/abyme/tree/v0.2.4) (2020-10-18)
|
data/Gemfile.lock
CHANGED
@@ -1,61 +1,61 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
abyme (0.
|
4
|
+
abyme (0.6.3)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
actioncable (6.0.3.
|
10
|
-
actionpack (= 6.0.3.
|
9
|
+
actioncable (6.0.3.7)
|
10
|
+
actionpack (= 6.0.3.7)
|
11
11
|
nio4r (~> 2.0)
|
12
12
|
websocket-driver (>= 0.6.1)
|
13
|
-
actionmailbox (6.0.3.
|
14
|
-
actionpack (= 6.0.3.
|
15
|
-
activejob (= 6.0.3.
|
16
|
-
activerecord (= 6.0.3.
|
17
|
-
activestorage (= 6.0.3.
|
18
|
-
activesupport (= 6.0.3.
|
13
|
+
actionmailbox (6.0.3.7)
|
14
|
+
actionpack (= 6.0.3.7)
|
15
|
+
activejob (= 6.0.3.7)
|
16
|
+
activerecord (= 6.0.3.7)
|
17
|
+
activestorage (= 6.0.3.7)
|
18
|
+
activesupport (= 6.0.3.7)
|
19
19
|
mail (>= 2.7.1)
|
20
|
-
actionmailer (6.0.3.
|
21
|
-
actionpack (= 6.0.3.
|
22
|
-
actionview (= 6.0.3.
|
23
|
-
activejob (= 6.0.3.
|
20
|
+
actionmailer (6.0.3.7)
|
21
|
+
actionpack (= 6.0.3.7)
|
22
|
+
actionview (= 6.0.3.7)
|
23
|
+
activejob (= 6.0.3.7)
|
24
24
|
mail (~> 2.5, >= 2.5.4)
|
25
25
|
rails-dom-testing (~> 2.0)
|
26
|
-
actionpack (6.0.3.
|
27
|
-
actionview (= 6.0.3.
|
28
|
-
activesupport (= 6.0.3.
|
26
|
+
actionpack (6.0.3.7)
|
27
|
+
actionview (= 6.0.3.7)
|
28
|
+
activesupport (= 6.0.3.7)
|
29
29
|
rack (~> 2.0, >= 2.0.8)
|
30
30
|
rack-test (>= 0.6.3)
|
31
31
|
rails-dom-testing (~> 2.0)
|
32
32
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
33
|
-
actiontext (6.0.3.
|
34
|
-
actionpack (= 6.0.3.
|
35
|
-
activerecord (= 6.0.3.
|
36
|
-
activestorage (= 6.0.3.
|
37
|
-
activesupport (= 6.0.3.
|
33
|
+
actiontext (6.0.3.7)
|
34
|
+
actionpack (= 6.0.3.7)
|
35
|
+
activerecord (= 6.0.3.7)
|
36
|
+
activestorage (= 6.0.3.7)
|
37
|
+
activesupport (= 6.0.3.7)
|
38
38
|
nokogiri (>= 1.8.5)
|
39
|
-
actionview (6.0.3.
|
40
|
-
activesupport (= 6.0.3.
|
39
|
+
actionview (6.0.3.7)
|
40
|
+
activesupport (= 6.0.3.7)
|
41
41
|
builder (~> 3.1)
|
42
42
|
erubi (~> 1.4)
|
43
43
|
rails-dom-testing (~> 2.0)
|
44
44
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
45
|
-
activejob (6.0.3.
|
46
|
-
activesupport (= 6.0.3.
|
45
|
+
activejob (6.0.3.7)
|
46
|
+
activesupport (= 6.0.3.7)
|
47
47
|
globalid (>= 0.3.6)
|
48
|
-
activemodel (6.0.3.
|
49
|
-
activesupport (= 6.0.3.
|
50
|
-
activerecord (6.0.3.
|
51
|
-
activemodel (= 6.0.3.
|
52
|
-
activesupport (= 6.0.3.
|
53
|
-
activestorage (6.0.3.
|
54
|
-
actionpack (= 6.0.3.
|
55
|
-
activejob (= 6.0.3.
|
56
|
-
activerecord (= 6.0.3.
|
57
|
-
marcel (~> 0.
|
58
|
-
activesupport (6.0.3.
|
48
|
+
activemodel (6.0.3.7)
|
49
|
+
activesupport (= 6.0.3.7)
|
50
|
+
activerecord (6.0.3.7)
|
51
|
+
activemodel (= 6.0.3.7)
|
52
|
+
activesupport (= 6.0.3.7)
|
53
|
+
activestorage (6.0.3.7)
|
54
|
+
actionpack (= 6.0.3.7)
|
55
|
+
activejob (= 6.0.3.7)
|
56
|
+
activerecord (= 6.0.3.7)
|
57
|
+
marcel (~> 1.0.0)
|
58
|
+
activesupport (6.0.3.7)
|
59
59
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
60
60
|
i18n (>= 0.7, < 2)
|
61
61
|
minitest (~> 5.1)
|
@@ -65,74 +65,74 @@ GEM
|
|
65
65
|
public_suffix (>= 2.0.2, < 5.0)
|
66
66
|
bindex (0.8.1)
|
67
67
|
builder (3.2.4)
|
68
|
-
|
68
|
+
byebug (11.1.3)
|
69
|
+
capybara (3.35.3)
|
69
70
|
addressable
|
70
71
|
mini_mime (>= 0.1.3)
|
71
72
|
nokogiri (~> 1.8)
|
72
73
|
rack (>= 1.6.0)
|
73
74
|
rack-test (>= 0.6.3)
|
74
|
-
regexp_parser (
|
75
|
+
regexp_parser (>= 1.5, < 3.0)
|
75
76
|
xpath (~> 3.2)
|
76
77
|
childprocess (3.0.0)
|
77
78
|
coderay (1.1.3)
|
78
|
-
concurrent-ruby (1.1.
|
79
|
+
concurrent-ruby (1.1.9)
|
79
80
|
crass (1.0.6)
|
80
|
-
database_cleaner (
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
database_cleaner-active_record (2.0.1)
|
82
|
+
activerecord (>= 5.a)
|
83
|
+
database_cleaner-core (~> 2.0.0)
|
84
|
+
database_cleaner-core (2.0.1)
|
84
85
|
diff-lcs (1.4.4)
|
85
|
-
docile (1.
|
86
|
+
docile (1.4.0)
|
86
87
|
erubi (1.10.0)
|
87
88
|
generator_spec (0.9.4)
|
88
89
|
activesupport (>= 3.0.0)
|
89
90
|
railties (>= 3.0.0)
|
90
91
|
globalid (0.4.2)
|
91
92
|
activesupport (>= 4.2.0)
|
92
|
-
i18n (1.8.
|
93
|
+
i18n (1.8.10)
|
93
94
|
concurrent-ruby (~> 1.0)
|
94
|
-
loofah (2.
|
95
|
+
loofah (2.10.0)
|
95
96
|
crass (~> 1.0.2)
|
96
97
|
nokogiri (>= 1.5.9)
|
97
98
|
mail (2.7.1)
|
98
99
|
mini_mime (>= 0.1.1)
|
99
|
-
marcel (0.
|
100
|
-
mimemagic (~> 0.3.2)
|
100
|
+
marcel (1.0.1)
|
101
101
|
method_source (1.0.0)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
nokogiri (1.11.1)
|
102
|
+
mini_mime (1.1.0)
|
103
|
+
mini_portile2 (2.5.3)
|
104
|
+
minitest (5.14.4)
|
105
|
+
nio4r (2.5.7)
|
106
|
+
nokogiri (1.11.7)
|
108
107
|
mini_portile2 (~> 2.5.0)
|
109
108
|
racc (~> 1.4)
|
110
109
|
pry (0.13.1)
|
111
110
|
coderay (~> 1.1)
|
112
111
|
method_source (~> 1.0)
|
113
|
-
pry-
|
114
|
-
|
112
|
+
pry-byebug (3.9.0)
|
113
|
+
byebug (~> 11.0)
|
114
|
+
pry (~> 0.13.0)
|
115
115
|
public_suffix (4.0.6)
|
116
|
-
puma (5.
|
116
|
+
puma (5.3.2)
|
117
117
|
nio4r (~> 2.0)
|
118
118
|
racc (1.5.2)
|
119
119
|
rack (2.2.3)
|
120
120
|
rack-test (1.1.0)
|
121
121
|
rack (>= 1.0, < 3)
|
122
|
-
rails (6.0.3.
|
123
|
-
actioncable (= 6.0.3.
|
124
|
-
actionmailbox (= 6.0.3.
|
125
|
-
actionmailer (= 6.0.3.
|
126
|
-
actionpack (= 6.0.3.
|
127
|
-
actiontext (= 6.0.3.
|
128
|
-
actionview (= 6.0.3.
|
129
|
-
activejob (= 6.0.3.
|
130
|
-
activemodel (= 6.0.3.
|
131
|
-
activerecord (= 6.0.3.
|
132
|
-
activestorage (= 6.0.3.
|
133
|
-
activesupport (= 6.0.3.
|
122
|
+
rails (6.0.3.7)
|
123
|
+
actioncable (= 6.0.3.7)
|
124
|
+
actionmailbox (= 6.0.3.7)
|
125
|
+
actionmailer (= 6.0.3.7)
|
126
|
+
actionpack (= 6.0.3.7)
|
127
|
+
actiontext (= 6.0.3.7)
|
128
|
+
actionview (= 6.0.3.7)
|
129
|
+
activejob (= 6.0.3.7)
|
130
|
+
activemodel (= 6.0.3.7)
|
131
|
+
activerecord (= 6.0.3.7)
|
132
|
+
activestorage (= 6.0.3.7)
|
133
|
+
activesupport (= 6.0.3.7)
|
134
134
|
bundler (>= 1.3.0)
|
135
|
-
railties (= 6.0.3.
|
135
|
+
railties (= 6.0.3.7)
|
136
136
|
sprockets-rails (>= 2.0.0)
|
137
137
|
rails-controller-testing (1.0.5)
|
138
138
|
actionpack (>= 5.0.1.rc1)
|
@@ -143,14 +143,14 @@ GEM
|
|
143
143
|
nokogiri (>= 1.6)
|
144
144
|
rails-html-sanitizer (1.3.0)
|
145
145
|
loofah (~> 2.3)
|
146
|
-
railties (6.0.3.
|
147
|
-
actionpack (= 6.0.3.
|
148
|
-
activesupport (= 6.0.3.
|
146
|
+
railties (6.0.3.7)
|
147
|
+
actionpack (= 6.0.3.7)
|
148
|
+
activesupport (= 6.0.3.7)
|
149
149
|
method_source
|
150
150
|
rake (>= 0.8.7)
|
151
151
|
thor (>= 0.20.3, < 2.0)
|
152
152
|
rake (13.0.3)
|
153
|
-
regexp_parser (1.
|
153
|
+
regexp_parser (2.1.1)
|
154
154
|
rspec-core (3.10.1)
|
155
155
|
rspec-support (~> 3.10.0)
|
156
156
|
rspec-expectations (3.10.1)
|
@@ -159,10 +159,10 @@ GEM
|
|
159
159
|
rspec-mocks (3.10.2)
|
160
160
|
diff-lcs (>= 1.2.0, < 2.0)
|
161
161
|
rspec-support (~> 3.10.0)
|
162
|
-
rspec-rails (
|
163
|
-
actionpack (>=
|
164
|
-
activesupport (>=
|
165
|
-
railties (>=
|
162
|
+
rspec-rails (5.0.1)
|
163
|
+
actionpack (>= 5.2)
|
164
|
+
activesupport (>= 5.2)
|
165
|
+
railties (>= 5.2)
|
166
166
|
rspec-core (~> 3.10)
|
167
167
|
rspec-expectations (~> 3.10)
|
168
168
|
rspec-mocks (~> 3.10)
|
@@ -172,11 +172,16 @@ GEM
|
|
172
172
|
selenium-webdriver (3.142.7)
|
173
173
|
childprocess (>= 0.5, < 4.0)
|
174
174
|
rubyzip (>= 1.2.2)
|
175
|
-
|
175
|
+
simple_form (5.1.0)
|
176
|
+
actionpack (>= 5.2)
|
177
|
+
activemodel (>= 5.2)
|
178
|
+
simplecov (0.21.2)
|
176
179
|
docile (~> 1.1)
|
177
180
|
simplecov-html (~> 0.11)
|
181
|
+
simplecov_json_formatter (~> 0.1)
|
178
182
|
simplecov-html (0.12.3)
|
179
183
|
simplecov-lcov (0.8.0)
|
184
|
+
simplecov_json_formatter (0.1.3)
|
180
185
|
sprockets (4.0.2)
|
181
186
|
concurrent-ruby (~> 1.0)
|
182
187
|
rack (> 1, < 3)
|
@@ -194,11 +199,11 @@ GEM
|
|
194
199
|
activemodel (>= 6.0.0)
|
195
200
|
bindex (>= 0.4.0)
|
196
201
|
railties (>= 6.0.0)
|
197
|
-
webdrivers (4.
|
202
|
+
webdrivers (4.6.0)
|
198
203
|
nokogiri (~> 1.6)
|
199
204
|
rubyzip (>= 1.3.0)
|
200
205
|
selenium-webdriver (>= 3.0, < 4.0)
|
201
|
-
websocket-driver (0.7.
|
206
|
+
websocket-driver (0.7.5)
|
202
207
|
websocket-extensions (>= 0.1.0)
|
203
208
|
websocket-extensions (0.1.5)
|
204
209
|
xpath (3.2.0)
|
@@ -211,15 +216,17 @@ PLATFORMS
|
|
211
216
|
DEPENDENCIES
|
212
217
|
abyme!
|
213
218
|
bundler (~> 2.0)
|
219
|
+
byebug
|
214
220
|
capybara
|
215
221
|
database_cleaner-active_record
|
216
222
|
generator_spec
|
217
|
-
pry-
|
223
|
+
pry-byebug
|
218
224
|
puma
|
219
|
-
rails
|
225
|
+
rails (~> 6.0.3.6)
|
220
226
|
rails-controller-testing
|
221
227
|
rake (~> 13.0)
|
222
228
|
rspec-rails
|
229
|
+
simple_form
|
223
230
|
simplecov
|
224
231
|
simplecov-lcov
|
225
232
|
sqlite3
|
@@ -227,4 +234,4 @@ DEPENDENCIES
|
|
227
234
|
webdrivers
|
228
235
|
|
229
236
|
BUNDLED WITH
|
230
|
-
2.
|
237
|
+
2.2.13
|
data/README.md
CHANGED
@@ -3,17 +3,18 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/abyme.svg)](https://badge.fury.io/rb/abyme)
|
4
4
|
![build](https://github.com/bear-in-mind/abyme/workflows/build/badge.svg)
|
5
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/f591a9e00f7cf5188ad5/maintainability)](https://codeclimate.com/github/bear-in-mind/abyme/maintainability)
|
6
|
-
[![Coverage Status](https://coveralls.io/repos/github/bear-in-mind/abyme/badge.svg)](https://coveralls.io/github/bear-in-mind/abyme?branch=master)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/github/bear-in-mind/abyme/badge.svg?branch=master)](https://coveralls.io/github/bear-in-mind/abyme?branch=master)
|
7
7
|
|
8
|
-
abyme is an easy and
|
8
|
+
abyme is an easy and form-agnostic way to handle nested attributes in Rails, using [stimulus](https://stimulusjs.org/handbook/introduction) under the hood. Here's an example :
|
9
9
|
```ruby
|
10
10
|
# views/projects/_form.html.erb
|
11
11
|
<%= form_for @project do |f| %>
|
12
12
|
<%= f.text_field :title %>
|
13
13
|
<%= f.text_area :description %>
|
14
|
-
|
15
|
-
|
14
|
+
|
16
15
|
<%= f.abyme_for(:tasks) %>
|
16
|
+
|
17
|
+
<%= f.submit 'Save' %>
|
17
18
|
<% end %>
|
18
19
|
```
|
19
20
|
Supposing you have a `Project` that `has_many :tasks` and a partial located in `views/abyme/_task_fields` containing your form fields for `tasks`, the `abyme_for` command will generate and display 3 elements in this order :
|
@@ -31,17 +32,6 @@ Check out our demo app here : https://abyme-demo.herokuapp.com/
|
|
31
32
|
|
32
33
|
Source code is right here : https://github.com/bear-in-mind/abyme_demo
|
33
34
|
|
34
|
-
## Breaking changes
|
35
|
-
Careful ! As of February 12th, we changed quite a few methods name :
|
36
|
-
In model:
|
37
|
-
- `abyme_for` became `abymize`
|
38
|
-
In views:
|
39
|
-
- `abymize(:association, f)` became `f.abyme_for(:association)`
|
40
|
-
- `add_association` became `add_associated_record`
|
41
|
-
- `remove_association` became `remove_associated_record`
|
42
|
-
|
43
|
-
If you update, don't forget to change those ! All changes are reflected in the README below.
|
44
|
-
|
45
35
|
## Installation
|
46
36
|
|
47
37
|
Add this line to your application's Gemfile:
|
@@ -56,7 +46,12 @@ And then execute:
|
|
56
46
|
$ yarn add abyme
|
57
47
|
|
58
48
|
|
59
|
-
Assuming you [already installed Stimulus](https://stimulusjs.org/handbook/introduction),
|
49
|
+
Assuming you [already installed Stimulus](https://stimulusjs.org/handbook/introduction), you need to register the `stimulus` controller that takes care of the JavaScript behaviour. You can launch this generator :
|
50
|
+
```bash
|
51
|
+
rails generate abyme:stimulus
|
52
|
+
```
|
53
|
+
Or you can register it yourself :
|
54
|
+
|
60
55
|
```javascript
|
61
56
|
// app/javascript/controllers/index.js
|
62
57
|
import { Application } from "stimulus"
|
@@ -71,12 +66,53 @@ application.load(definitionsFromContext(context))
|
|
71
66
|
application.register('abyme', AbymeController)
|
72
67
|
```
|
73
68
|
|
74
|
-
##
|
69
|
+
## Getting started
|
75
70
|
|
76
71
|
To learn more about the *why* of this gem, check out our [wiki](https://github.com/bear-in-mind/abyme/wiki/What-are-nested-forms-and-why-a-new-gem-%3F)
|
77
72
|
|
78
|
-
You may also check out our [step by step tutorial](https://github.com/bear-in-mind/abyme/wiki/Step-by-step-Tutorial)
|
73
|
+
You may also check out our [step by step tutorial](https://github.com/bear-in-mind/abyme/wiki/Step-by-step-Tutorial) and our [advanced configuration guide](https://github.com/bear-in-mind/abyme/wiki/Step-by-step-:-Advanced-configuration) (currently in construction).
|
74
|
+
## Documentation
|
75
|
+
As in our [our tutorial](https://github.com/bear-in-mind/abyme/wiki/Step-by-step-Tutorial), we'll assume we have a `Project` model, that `has_many :tasks` for the rest of the documentation.
|
76
|
+
### Generators
|
77
|
+
To be up and running in no time, we built a few generators. Feel free to skip these if you prefer a manual implementation.
|
78
|
+
#### Resource
|
79
|
+
To generate everything you need with one command, use this generator :
|
80
|
+
```bash
|
81
|
+
rails generate abyme:resource project tasks
|
82
|
+
# Includes configuration in Project model
|
83
|
+
# Adds abyme_attributes in ProjectsController permitted params
|
84
|
+
# Creates a partial and minimum boilerplate in app/views/abyme/_task_fields.html.erb
|
85
|
+
```
|
86
|
+
Now, head to your parent form and [keep reading](https://github.com/eki-177/abyme#abyme_forassociation-options---block) !
|
87
|
+
|
88
|
+
You can also specify [attributes to be permitted](https://github.com/eki-177/abyme#model), or permit all of them (see below). This will populate the partial with input fields for the specified attributes
|
89
|
+
```bash
|
90
|
+
rails generate abyme:resource project tasks description title
|
91
|
+
# Includes configuration in Project model, including permitted attributes
|
92
|
+
# Adds abyme_attributes in ProjectsController permitted params
|
93
|
+
# Creates a partial with input fields for the specified attributes in app/views/abyme/_task_fields.html.erb
|
94
|
+
```
|
79
95
|
|
96
|
+
#### Individual generators
|
97
|
+
All the generators launched by the main `resource` generator are available individually :
|
98
|
+
```bash
|
99
|
+
# Controller
|
100
|
+
rails generate abyme:controller Projects
|
101
|
+
|
102
|
+
# Model
|
103
|
+
# Permit only a few attributes
|
104
|
+
rails generate abyme:model project tasks description title
|
105
|
+
# Permit all attributes
|
106
|
+
rails generate abyme:model project participants all_attributes
|
107
|
+
|
108
|
+
# Views
|
109
|
+
# Without attributes (use this if you're not using SimpleForm or don't care about generating input fields)
|
110
|
+
rails generate abyme:view tasks
|
111
|
+
# With a few attributes
|
112
|
+
rails generate abyme:view tasks name description
|
113
|
+
# With all attributes
|
114
|
+
rails generate abyme:view tasks all_attributes
|
115
|
+
```
|
80
116
|
|
81
117
|
### Model
|
82
118
|
|
@@ -135,7 +171,7 @@ This is the container for all your nested fields. It takes the symbolized associ
|
|
135
171
|
<%= f.abyme_for(:tasks, partial: 'projects/task_fields') do |abyme| %>
|
136
172
|
<%= abyme.records %>
|
137
173
|
<%= abyme.new_records %>
|
138
|
-
<%=
|
174
|
+
<%= add_associated_record %>
|
139
175
|
<% end %>
|
140
176
|
```
|
141
177
|
* `limit: ` : allows you to limit the number of new fields that can be created through JS. If you need to limit the number of associations in database, you will need to add validations. You can also pass an option [in your model as well](https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for).
|
@@ -144,7 +180,7 @@ This is the container for all your nested fields. It takes the symbolized associ
|
|
144
180
|
# Beyond 5 tasks, the add button won't add any more fields. See events section below to see how to handle the 'abyme:limit-reached' event
|
145
181
|
<%= abyme.records %>
|
146
182
|
<%= abyme.new_records %>
|
147
|
-
<%=
|
183
|
+
<%= add_associated_record %>
|
148
184
|
<% end %>
|
149
185
|
```
|
150
186
|
* `min_count: ` by default, there won't be any blank fields added on page load. By passing a `min_count` option, you can set how many empty fields should appear in the form.
|
@@ -153,7 +189,7 @@ This is the container for all your nested fields. It takes the symbolized associ
|
|
153
189
|
# 1 blank task will automatically be added to the form.
|
154
190
|
<%= abyme.records %>
|
155
191
|
<%= abyme.new_records %>
|
156
|
-
<%=
|
192
|
+
<%= add_associated_record %>
|
157
193
|
<% end %>
|
158
194
|
```
|
159
195
|
|
@@ -272,7 +308,7 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
272
308
|
|
273
309
|
## Contributing
|
274
310
|
|
275
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
311
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/eki-177/abyme.
|
276
312
|
|
277
313
|
## License
|
278
314
|
|