abyme 0.5.1 → 0.6.4
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/Gemfile.lock +91 -86
- data/README.md +57 -22
- data/abyme.gemspec +6 -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/model.rb +16 -16
- data/lib/abyme/version.rb +2 -2
- data/lib/abyme/view_helpers.rb +67 -52
- 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 +69 -0
- data/lib/templates/erb/scaffold/_form.html.erb +15 -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 +56 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa7e981607f8bab371a8cef7529510076e0095db0b3c1908ba045e21df10a476
|
4
|
+
data.tar.gz: f25822329ba46b8418e4d0507291b590a3ce3e9b1f2ff2a7b25ff78821fbb0dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77ea88778c1373472d1c8af396e235e6d51331ffabab8b613763a0fabb89ced08d76d0741af52254774d80011a2a77786520fd52f4385de8e212b5f3858884f4
|
7
|
+
data.tar.gz: 999cadbcf32145e4f1968815779d1828f04a272c1923135a5a049b40e676889755349c19b377f1b97913301b15ffce2650e9f4641442b4037d4851a1ba73b353
|
data/.DS_Store
CHANGED
Binary file
|
data/.babelrc
ADDED
data/Gemfile.lock
CHANGED
@@ -1,61 +1,61 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
abyme (0.
|
4
|
+
abyme (0.6.4)
|
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,72 @@ 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
|
-
nio4r (2.5.4)
|
107
|
-
nokogiri (1.11.1)
|
108
|
-
mini_portile2 (~> 2.5.0)
|
102
|
+
mini_mime (1.1.0)
|
103
|
+
minitest (5.14.4)
|
104
|
+
nio4r (2.5.7)
|
105
|
+
nokogiri (1.11.7-x86_64-darwin)
|
109
106
|
racc (~> 1.4)
|
110
107
|
pry (0.13.1)
|
111
108
|
coderay (~> 1.1)
|
112
109
|
method_source (~> 1.0)
|
113
|
-
pry-
|
114
|
-
|
110
|
+
pry-byebug (3.9.0)
|
111
|
+
byebug (~> 11.0)
|
112
|
+
pry (~> 0.13.0)
|
115
113
|
public_suffix (4.0.6)
|
116
|
-
puma (5.
|
114
|
+
puma (5.3.2)
|
117
115
|
nio4r (~> 2.0)
|
118
116
|
racc (1.5.2)
|
119
117
|
rack (2.2.3)
|
120
118
|
rack-test (1.1.0)
|
121
119
|
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.
|
120
|
+
rails (6.0.3.7)
|
121
|
+
actioncable (= 6.0.3.7)
|
122
|
+
actionmailbox (= 6.0.3.7)
|
123
|
+
actionmailer (= 6.0.3.7)
|
124
|
+
actionpack (= 6.0.3.7)
|
125
|
+
actiontext (= 6.0.3.7)
|
126
|
+
actionview (= 6.0.3.7)
|
127
|
+
activejob (= 6.0.3.7)
|
128
|
+
activemodel (= 6.0.3.7)
|
129
|
+
activerecord (= 6.0.3.7)
|
130
|
+
activestorage (= 6.0.3.7)
|
131
|
+
activesupport (= 6.0.3.7)
|
134
132
|
bundler (>= 1.3.0)
|
135
|
-
railties (= 6.0.3.
|
133
|
+
railties (= 6.0.3.7)
|
136
134
|
sprockets-rails (>= 2.0.0)
|
137
135
|
rails-controller-testing (1.0.5)
|
138
136
|
actionpack (>= 5.0.1.rc1)
|
@@ -143,14 +141,14 @@ GEM
|
|
143
141
|
nokogiri (>= 1.6)
|
144
142
|
rails-html-sanitizer (1.3.0)
|
145
143
|
loofah (~> 2.3)
|
146
|
-
railties (6.0.3.
|
147
|
-
actionpack (= 6.0.3.
|
148
|
-
activesupport (= 6.0.3.
|
144
|
+
railties (6.0.3.7)
|
145
|
+
actionpack (= 6.0.3.7)
|
146
|
+
activesupport (= 6.0.3.7)
|
149
147
|
method_source
|
150
148
|
rake (>= 0.8.7)
|
151
149
|
thor (>= 0.20.3, < 2.0)
|
152
150
|
rake (13.0.3)
|
153
|
-
regexp_parser (1.
|
151
|
+
regexp_parser (2.1.1)
|
154
152
|
rspec-core (3.10.1)
|
155
153
|
rspec-support (~> 3.10.0)
|
156
154
|
rspec-expectations (3.10.1)
|
@@ -159,10 +157,10 @@ GEM
|
|
159
157
|
rspec-mocks (3.10.2)
|
160
158
|
diff-lcs (>= 1.2.0, < 2.0)
|
161
159
|
rspec-support (~> 3.10.0)
|
162
|
-
rspec-rails (
|
163
|
-
actionpack (>=
|
164
|
-
activesupport (>=
|
165
|
-
railties (>=
|
160
|
+
rspec-rails (5.0.1)
|
161
|
+
actionpack (>= 5.2)
|
162
|
+
activesupport (>= 5.2)
|
163
|
+
railties (>= 5.2)
|
166
164
|
rspec-core (~> 3.10)
|
167
165
|
rspec-expectations (~> 3.10)
|
168
166
|
rspec-mocks (~> 3.10)
|
@@ -172,11 +170,16 @@ GEM
|
|
172
170
|
selenium-webdriver (3.142.7)
|
173
171
|
childprocess (>= 0.5, < 4.0)
|
174
172
|
rubyzip (>= 1.2.2)
|
175
|
-
|
173
|
+
simple_form (5.1.0)
|
174
|
+
actionpack (>= 5.2)
|
175
|
+
activemodel (>= 5.2)
|
176
|
+
simplecov (0.21.2)
|
176
177
|
docile (~> 1.1)
|
177
178
|
simplecov-html (~> 0.11)
|
179
|
+
simplecov_json_formatter (~> 0.1)
|
178
180
|
simplecov-html (0.12.3)
|
179
181
|
simplecov-lcov (0.8.0)
|
182
|
+
simplecov_json_formatter (0.1.3)
|
180
183
|
sprockets (4.0.2)
|
181
184
|
concurrent-ruby (~> 1.0)
|
182
185
|
rack (> 1, < 3)
|
@@ -194,11 +197,11 @@ GEM
|
|
194
197
|
activemodel (>= 6.0.0)
|
195
198
|
bindex (>= 0.4.0)
|
196
199
|
railties (>= 6.0.0)
|
197
|
-
webdrivers (4.
|
200
|
+
webdrivers (4.6.0)
|
198
201
|
nokogiri (~> 1.6)
|
199
202
|
rubyzip (>= 1.3.0)
|
200
203
|
selenium-webdriver (>= 3.0, < 4.0)
|
201
|
-
websocket-driver (0.7.
|
204
|
+
websocket-driver (0.7.5)
|
202
205
|
websocket-extensions (>= 0.1.0)
|
203
206
|
websocket-extensions (0.1.5)
|
204
207
|
xpath (3.2.0)
|
@@ -206,20 +209,22 @@ GEM
|
|
206
209
|
zeitwerk (2.4.2)
|
207
210
|
|
208
211
|
PLATFORMS
|
209
|
-
|
212
|
+
x86_64-darwin-19
|
210
213
|
|
211
214
|
DEPENDENCIES
|
212
215
|
abyme!
|
213
216
|
bundler (~> 2.0)
|
217
|
+
byebug
|
214
218
|
capybara
|
215
219
|
database_cleaner-active_record
|
216
220
|
generator_spec
|
217
|
-
pry-
|
221
|
+
pry-byebug
|
218
222
|
puma
|
219
|
-
rails
|
223
|
+
rails (~> 6.0.3.6)
|
220
224
|
rails-controller-testing
|
221
225
|
rake (~> 13.0)
|
222
226
|
rspec-rails
|
227
|
+
simple_form
|
223
228
|
simplecov
|
224
229
|
simplecov-lcov
|
225
230
|
sqlite3
|
@@ -227,4 +232,4 @@ DEPENDENCIES
|
|
227
232
|
webdrivers
|
228
233
|
|
229
234
|
BUNDLED WITH
|
230
|
-
2.
|
235
|
+
2.2.13
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
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
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
|
@@ -11,9 +11,10 @@ abyme is an easy and form-agnostic way to handle nested attributes in Rails, usi
|
|
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,18 +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
|
-
The former method names will be deprecated soon.
|
44
|
-
If you update, don't forget to change those ! All changes are reflected in the README below.
|
45
|
-
|
46
35
|
## Installation
|
47
36
|
|
48
37
|
Add this line to your application's Gemfile:
|
@@ -57,7 +46,12 @@ And then execute:
|
|
57
46
|
$ yarn add abyme
|
58
47
|
|
59
48
|
|
60
|
-
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
|
+
|
61
55
|
```javascript
|
62
56
|
// app/javascript/controllers/index.js
|
63
57
|
import { Application } from "stimulus"
|
@@ -72,12 +66,53 @@ application.load(definitionsFromContext(context))
|
|
72
66
|
application.register('abyme', AbymeController)
|
73
67
|
```
|
74
68
|
|
75
|
-
##
|
69
|
+
## Getting started
|
76
70
|
|
77
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)
|
78
72
|
|
79
|
-
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
|
+
```
|
80
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
|
+
```
|
81
116
|
|
82
117
|
### Model
|
83
118
|
|
@@ -136,7 +171,7 @@ This is the container for all your nested fields. It takes the symbolized associ
|
|
136
171
|
<%= f.abyme_for(:tasks, partial: 'projects/task_fields') do |abyme| %>
|
137
172
|
<%= abyme.records %>
|
138
173
|
<%= abyme.new_records %>
|
139
|
-
<%=
|
174
|
+
<%= add_associated_record %>
|
140
175
|
<% end %>
|
141
176
|
```
|
142
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).
|
@@ -145,7 +180,7 @@ This is the container for all your nested fields. It takes the symbolized associ
|
|
145
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
|
146
181
|
<%= abyme.records %>
|
147
182
|
<%= abyme.new_records %>
|
148
|
-
<%=
|
183
|
+
<%= add_associated_record %>
|
149
184
|
<% end %>
|
150
185
|
```
|
151
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.
|
@@ -154,7 +189,7 @@ This is the container for all your nested fields. It takes the symbolized associ
|
|
154
189
|
# 1 blank task will automatically be added to the form.
|
155
190
|
<%= abyme.records %>
|
156
191
|
<%= abyme.new_records %>
|
157
|
-
<%=
|
192
|
+
<%= add_associated_record %>
|
158
193
|
<% end %>
|
159
194
|
```
|
160
195
|
|
@@ -273,7 +308,7 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
273
308
|
|
274
309
|
## Contributing
|
275
310
|
|
276
|
-
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.
|
277
312
|
|
278
313
|
## License
|
279
314
|
|