bullet_train 1.5.2 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26d50ad6167e3e1f7d3b8a550313094548a2b82bba8c60106ec8549db38abd51
4
- data.tar.gz: ffe18a2a1265a052929fc52bd9213de99f565327384d022bf644b43cb4aa3174
3
+ metadata.gz: b1acc9aef5bfdec082aae9de0b523afc27395b9b41022ec4cf243e83a1d36e75
4
+ data.tar.gz: fef8231d3e320ce6b23978924b9a132585fae765842743112482f7bdbd2bb7e7
5
5
  SHA512:
6
- metadata.gz: d7e1ddd05c6a9bebad198f5cf6e48db86e09fa8194ef8ae5cc83bb12a141efe174716ea98b6b6b3032cc13a4d466dd6ed3a85dd044643aa717c3a72a58ba5c75
7
- data.tar.gz: 04c8e18fea2b7db8ed9e08876cfa2f0fb51264f99c4cfb1a54323bb3497f3c7f2a42a4699cadaefe8ca639f42a78391138b79424e3a8493de6721efa85e6fbb2
6
+ metadata.gz: ebbab67c9b4ed7880f6ee020bddc7e6ed1cd337604835a76a5b0402fc962a60f24aa851e07806cba4bc8c7adc562c0b9242a17904321b3516bb41fa977934ce9
7
+ data.tar.gz: 8f6bf47611928395122564d43b85bb2c121843a651ce49201a41383b40c8e4c2b1802d6b1e300420180e62327cfaff4901654cd5127bb86a83f589c03e037126
@@ -73,7 +73,6 @@ bin/super-scaffold action-model:targets-one-parent
73
73
  ### 1. Generate and scaffold an example `Project` model.
74
74
 
75
75
  ```
76
- rails g model Project team:references name:string
77
76
  bin/super-scaffold crud Project Team name:text_field
78
77
  ```
79
78
 
@@ -104,7 +103,6 @@ Because Action Models are just regular models, you can add new fields to them wi
104
103
  For example:
105
104
 
106
105
  ```
107
- rails g migration add_notify_users_to_projects_archive_actions notify_users:boolean
108
106
  # side quest: update the generated migration with `default: false` on the new boolean field.
109
107
  bin/super-scaffold crud-field Projects::ArchiveAction notify_users:boolean
110
108
  ```
@@ -47,6 +47,5 @@ Run the following command to generate the scaffolding for the `documents` field
47
47
  If you're starting fresh, and don't have an existing model you can do something like this:
48
48
 
49
49
  ```
50
- rails g model Project team:references name:string specification:attachment documents:attachments
51
50
  bin/super-scaffold crud Project Team name:text_field specification:file_field documents:file_field{multiple}
52
51
  ```
@@ -147,12 +147,15 @@ Certain form field partials like `buttons` and `super_select` can also have thei
147
147
  For Cloudinary you should use `string`, and for ActiveStorage you should use `attachment`.
148
148
 
149
149
  ## A Note On Data Types
150
- Set the data type to `jsonb` whenever passing the `multiple` option to a new attribute.
150
+ When creating a `multiple` option attribute, Bullet Train generates these values as a `jsonb`.
151
151
  ```
152
- > rails generate model Project team:references multiple_buttons:jsonb
153
- > bin/super-scaffold crud Project Team multiple_buttons:buttons{multiple}
152
+ bin/super-scaffold crud Project Team multiple_buttons:buttons{multiple}
154
153
  ```
155
154
 
155
+ This will run the following rails command.
156
+ ```
157
+ rails generate model Project team:references multiple_buttons:jsonb
158
+ ```
156
159
  ## Formating `date` and `date_and_time`
157
160
  After Super Scaffolding a `date` or `date_and_time` field, you can pass a format for the object like so:
158
161
 
@@ -8,16 +8,15 @@ Whether you want to build a new application with Bullet Train or contribute to B
8
8
 
9
9
  If you're using Bullet Train for the first time, begin by learning these five important techniques:
10
10
 
11
- 1. Use `rails g model` to create and `bin/super-scaffold crud` to scaffold a new model:
11
+ 1. Use `bin/super-scaffold crud` to scaffold a new model:
12
12
 
13
13
  ```
14
- rails g model Project team:references name:string
15
14
  bin/super-scaffold crud Project Team name:text_field
16
15
  ```
17
16
 
18
17
  In this example, `Team` refers to the immediate parent of the `Project` resource. For more details, just run `bin/super-scaffold` or [read the documentation](/docs/super-scaffolding.md).
19
18
 
20
- 2. Use `rails g migration` and `bin/super-scaffold crud-field` to add a new field to a model you've already scaffolded:
19
+ 2. Use `bin/super-scaffold crud-field` to add a new field to a model you've already scaffolded:
21
20
 
22
21
  ```
23
22
  rails g migration add_description_to_projects description:text
data/docs/modeling.md CHANGED
@@ -68,7 +68,7 @@ Even if you know there's an attribute or model that you're going to want to poli
68
68
 
69
69
  ## A Systematic Approach
70
70
 
71
- ### 1. Write `rails g` and `bin/super-scaffold` commands in a scratch file.
71
+ ### 1. Write `bin/super-scaffold` commands in a scratch file.
72
72
 
73
73
  See the [Super Scaffolding documentation](/docs/super-scaffolding.md) for more specific guidance. Leave plenty of comments in your scratch file describing anything that isn't obvious and providing examples of values that might populate attributes.
74
74
 
@@ -39,7 +39,7 @@ Note that in this specific approach we don't need a `team:references` on `Messag
39
39
  ### 2. Super Scaffolding for `Entry`
40
40
 
41
41
  ```
42
- bin/super-scaffold crud Entry Team entryable_type:buttons
42
+ bin/super-scaffold crud Entry Team entryable_type:buttons --skip-migration-generation
43
43
  ```
44
44
 
45
45
  We use `entryable_type:buttons` because we're going to allow people to choose which type of `Entry` they're creating with a list of buttons. This isn't the only option available to us, but it's the easiest to implement for now.
@@ -41,25 +41,28 @@ Let's implement the following feature:
41
41
 
42
42
  > An organization has many projects.
43
43
 
44
- First, generate the model with the standard Rails generator:
44
+ First, run the `crud` scaffolder:
45
+ ```
46
+ bin/super-scaffold crud Project Team name:text_field
47
+ rake db:migrate
48
+ ```
49
+
50
+ In the above example, `team` represents the model that a `Project` primarily belongs to. Also, `text_field` was selected from [the list of available field partials](/docs/field-partials.md). We'll show examples with `trix_editor` and `super_select` later.
51
+
52
+ Super Scaffolding automatically generates models for you. However, if you want to split this process, you can pass the `--skip-migration-generation` to the command.
45
53
 
54
+ For example, generate the model with the standard Rails generator:
46
55
  ```
47
56
  rails g model Project team:references name:string
48
57
  ```
49
58
 
50
- In the above example, `team` represents the model that a `Project` primarily belongs to.
51
-
52
59
  ⚠️ Don't run migrations right away. It would be fine in this case, but sometimes the subsequent Super Scaffolding step actually updates the migration as part of its magic.
53
60
 
54
- Next, run the `crud` scaffolder:
55
-
61
+ Then you can run the scaffolder with the flag:
56
62
  ```
57
- bin/super-scaffold crud Project Team name:text_field
58
- rake db:migrate
63
+ bin/super-scaffold crud Project Team name:text_field --skip-migration-generation
59
64
  ```
60
65
 
61
- In the above example, `text_field` was selected from [the list of available field partials](/docs/field-partials.md). We'll show examples with `trix_editor` and `super_select` later.
62
-
63
66
  ### 2. Nested CRUD Scaffolding with `crud`
64
67
 
65
68
  Building on that example, let's implement the following feature:
@@ -68,22 +71,14 @@ Building on that example, let's implement the following feature:
68
71
  A project has many goals.
69
72
  ```
70
73
 
71
- Again, we'll generate the model using the standard Rails generator:
72
-
73
- ```
74
- rails g model Goal project:references description:string
75
- ```
76
-
77
- You can see in the example above that there is no direct reference to team, but to `project` instead, since that's where a `Goal` belongs.
78
-
79
- Now, run the `crud` scaffolder:
74
+ First, run the `crud` scaffolder:
80
75
 
81
76
  ```
82
77
  bin/super-scaffold crud Goal Project,Team description:text_field
83
78
  rake db:migrate
84
79
  ```
85
80
 
86
- You can see in the example above how we've specified `Project,Team`, because we want to specify the entire chain of ownership back to the `Team`. This allows Super Scaffolding to automatically generate the required permissions.
81
+ You can see in the example above how we've specified `Project,Team`, because we want to specify the entire chain of ownership back to the `Team`. This allows Super Scaffolding to automatically generate the required permissions. Take note that this generates a foreign key for `Project` and not for `Team`.
87
82
 
88
83
  ### 3. Adding New Fields with `crud-field`
89
84
 
@@ -93,13 +88,7 @@ Building on the earlier example, consider the following new requirement:
93
88
 
94
89
  > In addition to a name, a project can have a description.
95
90
 
96
- First, use the standard Rails migration generator to add the attribute in the database:
97
-
98
- ```
99
- rails g migration add_description_to_projects description:text
100
- ```
101
-
102
- Then, use the `crud-field` scaffolder to add it throughout the application:
91
+ Use the `crud-field` scaffolder to add it throughout the application:
103
92
 
104
93
  ```
105
94
  bin/super-scaffold crud-field Project description:trix_editor
@@ -113,6 +102,11 @@ If you want to scaffold a new field to use for read-only purposes, add the follo
113
102
  bin/super-scaffold crud-field Project description:trix_editor{readonly}
114
103
  ```
115
104
 
105
+ Again, if you would like to automatically generate the migration on your own, pass the `--skip-migration-generation` flag:
106
+ ```
107
+ bin/super-scaffold crud-field Project description:trix_editor --skip-migration-generation
108
+ ```
109
+
116
110
  ### 4. Adding Option Fields with Fixed, Translatable Options
117
111
 
118
112
  Continuing with the earlier example, let's address the following new requirement:
@@ -124,7 +118,6 @@ We have multiple [field partials](/docs/field-partials.md) that we could use for
124
118
  In this example, let's add a status attribute and present it as buttons:
125
119
 
126
120
  ```
127
- rails g migration add_status_to_projects status:string
128
121
  bin/super-scaffold crud-field Project status:buttons
129
122
  ```
130
123
 
@@ -152,21 +145,16 @@ Although you might think this calls for a reference to `User`, we've learned the
152
145
 
153
146
  We can accomplish this like so:
154
147
 
155
- ```
156
- rails g migration add_lead_to_projects lead:references
157
- ```
158
-
159
- Then, to add the field, we specify the following:
160
-
161
148
  ```
162
149
  bin/super-scaffold crud-field Project lead_id:super_select{class_name=Membership}
163
150
  rake db:migrate
164
151
  ```
165
152
 
166
- There are two important things to point out here:
153
+ There are three important things to point out here:
167
154
 
168
- 1. When we use `rails g model` or `rails g migration`, we specify the `references` column name as `lead`, but when we're specifying the _field_ we want to scaffold, we specify it as `lead_id`, because that's the name of the attribute on the form, in strong parameters, etc.
169
- 2. We have to specify the model name with the `class_name` option so that Super Scaffolding can fully work it's magic. We can't reflect on the association, because at this point the association isn't properly defined yet. With this information, Super Scaffolding can handle that step for you.
155
+ 1. The scaffolder automatically adds a foreign key for `lead` to `Project`.
156
+ 2. When adding this foreign key the `references` column is generated under the name `lead`, but when we're specifying the _field_ we want to scaffold, we specify it as `lead_id`, because that's the name of the attribute on the form, in strong parameters, etc.
157
+ 3. We have to specify the model name with the `class_name` option so that Super Scaffolding can fully work it's magic. We can't reflect on the association, because at this point the association isn't properly defined yet. With this information, Super Scaffolding can handle that step for you.
170
158
 
171
159
  Finally, Super Scaffolding will prompt you to edit `app/models/project.rb` and implement the required logic in the `valid_leads` method. This is a template method that will be used to both populate the select field on the `Project` form, but also enforce some important security concerns in this multi-tenant system. In this case, you can define it as:
172
160
 
@@ -189,17 +177,12 @@ We can accomplish this with a new model, a new join model, and a `super_select`
189
177
  First, let's create the tag model:
190
178
 
191
179
  ```
192
- rails g model Projects::Tag team:references name:string
193
180
  bin/super-scaffold crud Projects::Tag Team name:text_field
194
181
  ```
195
182
 
196
183
  Note that project tags are specifically defined at the `Team` level. The same tag can be applied to multiple `Project` models.
197
184
 
198
- Now, let's create a join model for the has-many-through association:
199
-
200
- ```
201
- rails g model Projects::AppliedTag project:references tag:references
202
- ```
185
+ Now, let's create a join model for the has-many-through association.
203
186
 
204
187
  We're not going to scaffold this model with the typical `crud` scaffolder, but some preparation is needed before we can use it with the `crud-field` scaffolder, so we need to do the following:
205
188
 
@@ -237,34 +220,39 @@ Bullet Train comes with two different ways to handle image uploads.
237
220
 
238
221
  #### Scaffolding images with Cloudinary
239
222
 
240
- When you scaffold your model you need to include a `string` where Cloudinary can store a reference to the image.
223
+ When you scaffold your model a `string` is generated where Cloudinary can store a reference to the image.
224
+
225
+ Make sure you have the `CLOUDINARY_URL` environment variable to use Cloudinary for your images.
241
226
 
242
227
  For instance to scaffold a `Project` model with a `logo` image upload.
228
+ Use `image` as a field type for super scaffolding:
243
229
 
244
230
  ```
245
- rails g model Project team:references name:string logo:string
231
+ bin/super-scaffold crud Project Team name:text_field logo:image
232
+ rake db:migrate
246
233
  ```
247
234
 
248
- Then you can use `image` as a field type for super scaffolding:
249
-
235
+ Under the hood, Bullet Train will generate your model with the following command:
250
236
  ```
251
- bin/super-scaffold crud Project Team name:text_field logo:image
237
+ bin/super-scaffold crud Project Team name:text_field
252
238
  rake db:migrate
253
239
  ```
240
+
254
241
  #### Scaffolding images with ActiveStorage
255
242
 
256
- When you scaffold your model you need to generate an `attachment` type attribute.
243
+ When you scaffold your model we generate an `attachment` type attribute.
257
244
 
258
245
  For instance to scaffold a `Project` model with a `logo` image upload.
246
+ Use `image` as a field type for super scaffolding:
259
247
 
260
248
  ```
261
- rails g model Project team:references name:string logo:attachment
249
+ bin/super-scaffold crud Project Team name:text_field logo:image
250
+ rake db:migrate
262
251
  ```
263
252
 
264
- Then you can use `image` as a field type for super scaffolding:
265
-
253
+ Under the hood, Bullet Train will generate your model with the following command:
266
254
  ```
267
- bin/super-scaffold crud Project Team name:text_field logo:image
255
+ bin/super-scaffold crud Project Team name:text_field
268
256
  rake db:migrate
269
257
  ```
270
258
 
@@ -1,3 +1,3 @@
1
1
  module BulletTrain
2
- VERSION = "1.5.2"
2
+ VERSION = "1.6.0"
3
3
  end
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.5.2
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-03 00:00:00.000000000 Z
11
+ date: 2023-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard
@@ -164,20 +164,6 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: masamune-ast
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: 1.2.0
174
- type: :runtime
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: 1.2.0
181
167
  - !ruby/object:Gem::Dependency
182
168
  name: image_processing
183
169
  requirement: !ruby/object:Gem::Requirement