bullet_train 1.12.2 β 1.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/super-scaffolding/targets.md +104 -0
- data/docs/super-scaffolding.md +20 -0
- data/lib/bullet_train/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 918897d730dbf7dd7fd31f51609a2fbd25c56800a6442b3b0caa81ed7a9f8f40
|
4
|
+
data.tar.gz: 45a93a17f839e4a1e03a193f88cb6a8e23d81150bb17d8059473f4d86484cecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44f73475e4a154a35aa52ca0edb39900e23d286d1b870a1ba537a88997fdeac49986250719241ba081c8fecdf06c993436a753c569599862d9213f7e0123012b
|
7
|
+
data.tar.gz: ad26cf90042f42fec84595cf292bb9556131d0e2ffc40368857017e78c7aec83ea2e6430b9cc9ee601d41a942de06b3f34d484153f5bfabc8b325675c3c01f23
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# Targets for Super Scaffolding
|
2
|
+
|
3
|
+
Super Scaffolding relies on "magic comments" that we use as targets (also known as hooks) that help us put newly generated code in the right place.
|
4
|
+
|
5
|
+
For instance if you Super Scaffold a `Project` resource your model file will look like this:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
class Project < ApplicationRecord
|
9
|
+
# π
add concerns above.
|
10
|
+
|
11
|
+
# π
add attribute accessors above.
|
12
|
+
|
13
|
+
belongs_to :team
|
14
|
+
# π
add belongs_to associations above.
|
15
|
+
|
16
|
+
# π
add has_many associations above.
|
17
|
+
|
18
|
+
# π
add has_one associations above.
|
19
|
+
|
20
|
+
# π
add scopes above.
|
21
|
+
|
22
|
+
validates :name, presence: true
|
23
|
+
# π
add validations above.
|
24
|
+
|
25
|
+
# π
add callbacks above.
|
26
|
+
|
27
|
+
# π
add delegations above.
|
28
|
+
|
29
|
+
# π
add methods above.
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
All of those comments are used by the Super Scaffolder to put things in the right place.
|
34
|
+
|
35
|
+
**DON'T REMOVE THEM!**
|
36
|
+
|
37
|
+
If you remove them then we won't be able to make modifications to that file, and subsequent super scaffolding commands won't work correctly.
|
38
|
+
|
39
|
+
If you do remove them then you should see a warning the next time you try to add a field that requires modifications that model. (Not all attribute types do. File and Image fields are examples of ones that do.)
|
40
|
+
|
41
|
+
```
|
42
|
+
$ rails generate super_scaffold:field Project documents:file_field{multiple}
|
43
|
+
Adding new fields to Project with 'bin/rails generate migration add_documents_to_projects documents:attachments'
|
44
|
+
|
45
|
+
Updating './app/views/account/projects/_form.html.erb'.
|
46
|
+
Updating './app/views/account/projects/show.html.erb'.
|
47
|
+
Updating './app/views/account/projects/_index.html.erb'.
|
48
|
+
Replacing in './app/views/account/projects/_index.html.erb'.
|
49
|
+
Updating './app/views/account/projects/_project.html.erb'.
|
50
|
+
Updating './config/locales/en/projects.en.yml'.
|
51
|
+
Updating './config/locales/en/projects.en.yml'.
|
52
|
+
Updating './app/controllers/api/v1/projects_controller.rb'.
|
53
|
+
Updating './app/controllers/api/v1/projects_controller.rb'.
|
54
|
+
Updating './test/controllers/api/v1/projects_controller_test.rb'.
|
55
|
+
Updating './app/views/api/v1/projects/_project.json.jbuilder'.
|
56
|
+
Updating './test/controllers/api/v1/projects_controller_test.rb'.
|
57
|
+
|
58
|
+
-------------------------------
|
59
|
+
Heads up! We weren't able to find a super scaffolding hook where we expected it to be.
|
60
|
+
In ./app/models/project.rb
|
61
|
+
We expected to find a line like this:
|
62
|
+
# π
add has_many associations above.
|
63
|
+
|
64
|
+
See https://bullettrain.co/docs/super-scaffolding/targets for more details.
|
65
|
+
-------------------------------
|
66
|
+
|
67
|
+
|
68
|
+
-------------------------------
|
69
|
+
Heads up! We weren't able to find a super scaffolding hook where we expected it to be.
|
70
|
+
In ./app/models/project.rb
|
71
|
+
We expected to find a line like this:
|
72
|
+
# π
add attribute accessors above.
|
73
|
+
|
74
|
+
See https://bullettrain.co/docs/super-scaffolding/targets for more details.
|
75
|
+
-------------------------------
|
76
|
+
|
77
|
+
|
78
|
+
-------------------------------
|
79
|
+
Heads up! We weren't able to find a super scaffolding hook where we expected it to be.
|
80
|
+
In ./app/models/project.rb
|
81
|
+
We expected to find a line like this:
|
82
|
+
# π
add methods above.
|
83
|
+
|
84
|
+
See https://bullettrain.co/docs/super-scaffolding/targets for more details.
|
85
|
+
-------------------------------
|
86
|
+
|
87
|
+
|
88
|
+
-------------------------------
|
89
|
+
Heads up! We weren't able to find a super scaffolding hook where we expected it to be.
|
90
|
+
In ./app/models/project.rb
|
91
|
+
We expected to find a line like this:
|
92
|
+
# π
add callbacks above.
|
93
|
+
|
94
|
+
See https://bullettrain.co/docs/super-scaffolding/targets for more details.
|
95
|
+
-------------------------------
|
96
|
+
```
|
97
|
+
|
98
|
+
## How to Replace Missing Targets
|
99
|
+
|
100
|
+
If you've removed some targets and need to get them back you have a few options:
|
101
|
+
|
102
|
+
1. If the removal of the targets hasn't been committed to source control yet, you can use `git checkout` to restore the files to their previous state.
|
103
|
+
2. If the removal has been committed you could revert the commit that removed them.
|
104
|
+
3. You could use Super Scaffolding to generate a new resource and then copy & paste the targets from your new resource into the existing one.
|
data/docs/super-scaffolding.md
CHANGED
@@ -17,6 +17,8 @@ Hereβs a list of what Super Scaffolding takes care of for you each time you ad
|
|
17
17
|
|
18
18
|
When adding just one model, Super Scaffolding generates ~30 different files on your behalf.
|
19
19
|
|
20
|
+
**NOTE** Super Scaffolding generates code that contains special "magic comments" that we use as targets for later Super Scaffolding operations. You shouldn't remove those comments. See [Targets for Super Scaffolding](/docs/super-scaffolding/targets.md) for more details.
|
21
|
+
|
20
22
|
## Living Templates
|
21
23
|
|
22
24
|
Bullet Train's Super Scaffolding engine is a unique approach to code generation, based on template files that are functional code instead of obscure DSLs that are difficult to customize and maintain. Super Scaffolding automates the most repetitive and mundane aspects of building out your application's basic structure. Furthermore, it does this without leaning on the magic of libraries that force too high a level of abstraction. Instead, it generates standard Rails code that is both ready for prime time, but is also easy to customize and modify.
|
@@ -184,6 +186,20 @@ end
|
|
184
186
|
|
185
187
|
(The `current_and_invited` scope just filters out people that have already been removed from the team.)
|
186
188
|
|
189
|
+
**NOTE:** It's possible to define the source for `valid_leads` in your super scaffolding command.
|
190
|
+
You need to wrap the bits inside the curly brackets with double qoutes, and then add
|
191
|
+
`,source=team.memberships.current_and_invited` inside the quotes:
|
192
|
+
|
193
|
+
```
|
194
|
+
{"class_name=Membership,source=team.memberships.current_and_invited"}
|
195
|
+
```
|
196
|
+
|
197
|
+
So the whole command would be:
|
198
|
+
|
199
|
+
```
|
200
|
+
rails generate super_scaffold:field Project lead_id:super_select{"class_name=Membership,source=team.memberships.current_and_invited"}
|
201
|
+
```
|
202
|
+
|
187
203
|
### 6. Scaffolding Has-Many-Through Associations with `join_model`
|
188
204
|
|
189
205
|
Finally, working from the same example, imagine the following requirement:
|
@@ -299,3 +315,7 @@ HIDE_THINGS: true
|
|
299
315
|
- [Super Scaffolding Options](/docs/super-scaffolding/options.md)
|
300
316
|
- [Super Scaffolding with Delegated Types](/docs/super-scaffolding/delegated-types.md)
|
301
317
|
- [Super Scaffolding with the `--sortable` option](/docs/super-scaffolding/sortable.md)
|
318
|
+
|
319
|
+
## Additional Info
|
320
|
+
|
321
|
+
- [Targets for Super Scaffolding](/docs/super-scaffolding/targets.md)
|
data/lib/bullet_train/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -780,6 +780,7 @@ files:
|
|
780
780
|
- docs/super-scaffolding/delegated-types.md
|
781
781
|
- docs/super-scaffolding/options.md
|
782
782
|
- docs/super-scaffolding/sortable.md
|
783
|
+
- docs/super-scaffolding/targets.md
|
783
784
|
- docs/teams.md
|
784
785
|
- docs/testing.md
|
785
786
|
- docs/themes.md
|