hot-glue 0.2.6 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -2
  3. data/Gemfile.lock +3 -23
  4. data/LICENCE +11 -4
  5. data/README.md +0 -642
  6. data/app/helpers/hot_glue/controller_helper.rb +2 -1
  7. data/lib/generators/hot_glue/install_generator.rb +121 -33
  8. data/lib/generators/hot_glue/markup_templates/erb.rb +53 -27
  9. data/lib/generators/hot_glue/markup_templates/haml.rb +5 -3
  10. data/lib/generators/hot_glue/scaffold_generator.rb +224 -58
  11. data/lib/generators/hot_glue/templates/controller.rb.erb +39 -32
  12. data/lib/generators/hot_glue/templates/erb/_form.erb +1 -1
  13. data/lib/generators/hot_glue/templates/erb/_line.erb +3 -2
  14. data/lib/generators/hot_glue/templates/erb/_list.erb +24 -8
  15. data/lib/generators/hot_glue/templates/erb/_show.erb +27 -4
  16. data/lib/generators/hot_glue/templates/erb/create.turbo_stream.erb +4 -4
  17. data/lib/generators/hot_glue/templates/erb/destroy.turbo_stream.erb +2 -2
  18. data/lib/generators/hot_glue/templates/erb/edit.erb +2 -5
  19. data/lib/generators/hot_glue/templates/erb/index.erb +11 -9
  20. data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +5 -2
  21. data/lib/generators/hot_glue/templates/haml/_line.haml +1 -1
  22. data/lib/generators/hot_glue/templates/haml/_list.haml +6 -2
  23. data/lib/generators/hot_glue/templates/haml/create.turbo_stream.haml +3 -3
  24. data/lib/generators/hot_glue/templates/haml/destroy.turbo_stream.haml +1 -1
  25. data/lib/generators/hot_glue/templates/haml/edit.haml +0 -2
  26. data/lib/generators/hot_glue/templates/haml/index.haml +2 -3
  27. data/lib/generators/hot_glue/templates/system_spec.rb.erb +19 -8
  28. data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_dark_knight.scss +158 -0
  29. data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_bootstrap.scss +154 -0
  30. data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_los_gatos.scss +182 -0
  31. data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_mountain_view.scss +179 -0
  32. data/lib/hot-glue.rb +1 -2
  33. data/lib/hotglue/version.rb +1 -1
  34. metadata +13 -33
data/README.md CHANGED
@@ -1,642 +0,0 @@
1
-
2
- [![Build Status](https://app.travis-ci.com/jasonfb/hot-glue.svg?branch=main)](https://travis-ci.com/jasonfb/hot-glue)
3
-
4
-
5
- Hot Glue is a Rails scaffold builder for the Turbo era. It is an evolution of the admin-interface style scaffolding systems of the 2010s ([activeadmin](https://github.com/activeadmin/activeadmin), [rails_admin](https://github.com/sferik/rails_admin), and [active_scaffold](https://github.com/activescaffold/active_scaffold)).
6
-
7
-
8
- Using Turbo-Rails and Hotwire (default in Rails 7) you get a lightning-fast out-of-the-box CRUD building experience.
9
-
10
- Every page displays only a list view: new and edit operations happen as 'edit-in-place', so the user never leaves the page.
11
-
12
- Because all page navigation is Turbo's responsibilty, everything plugs & plays nicely into a Turbo-backed Rails app.
13
-
14
- Alternatively, you can use this tool to create a Turbo-backed *section* of your Rails app-- like an admin interface -- while still treating the rest of the Rails app as an API or building out other features by hand.
15
-
16
- It will read your relationships and field types to generate your code for you, leaving you with a 'sourdough starter' to work from. If you modify the generated code, you're on your own if you want to preserve your changes and also re-generate scaffold after adding fields.
17
-
18
- By default, it generates code that gives users full control over objects they 'own' and by default it spits out functionality giving access to all fields.
19
-
20
- Hot Glue generates functionality that's quick and dirty. It let's you be crafty. As with a real hot glue gun, use with caution.
21
-
22
- * Build plug-and-play scaffolding for any CRUD on any object
23
- * mixes HAML and turbo_stream responses
24
- * Everything edits-in-place (unless you use --big-edit, then it won't)
25
- * Automatically reads your ActiveRecord models and relationships (make them before building your scaffolding!)
26
- * Create-read-update-delete (CRUD) with pagination (one day: sorting & searching)
27
- * Excellent tool for prototyping and hackathons, but a knowledge of Rails is needed.
28
- * Nest your routes model-by-model for built-in poor man's access control. (Customers have_many :invoices; Invoices have_many :line_items; etc)
29
- * Plays nicely with Devise, but you can implement your own current_user object instead.
30
- * Kaminari for pagination.
31
- * Create specs automatically along with the controllers.
32
- * Throw the scaffolding away when your app is ready to graduate to its next phase (or don't if you like it).
33
-
34
- ## QUICK START
35
-
36
- It's really easy to get started by following along with this blog post that creates three simple tables (User, Event, and Format).
37
-
38
- Feel free to build your own tables when you get to the sections for building the 'Event' scaffold:
39
-
40
- https://jasonfleetwoodboldt.com/hot-glue
41
-
42
- ## HOW EASY?
43
-
44
- ```
45
- rails generate hot_glue:scaffold Thing
46
- ```
47
-
48
- Generate a quick scaffold to manage a table called `pronouns`
49
- ![hot-glue-3](https://user-images.githubusercontent.com/59002/116405509-bdee2f00-a7fd-11eb-9723-4c6e22f81bd3.gif)
50
-
51
-
52
-
53
- Instantly get a simple CRUD interface
54
-
55
- ![hot-glue-4](https://user-images.githubusercontent.com/59002/116405517-c2b2e300-a7fd-11eb-8423-d43e3afc9fa6.gif)
56
-
57
-
58
- ## ADD HOTWIRE
59
- ```
60
- yarn add @hotwired/turbo-rails
61
- ```
62
- or `npm install @hotwired/turbo-rails`
63
-
64
- ## ADD HOT-GLUE GEM
65
- - Add `gem 'hot-glue'` to your Gemfile & `bundle install`
66
-
67
- ## ADD RSPEC, FACTORY-BOT, AND FFAKER
68
-
69
- add these 3 gems to your gemfile inside :development and :test groups
70
- ```
71
- gem 'rspec-rails'
72
- gem 'factory_bot_rails'
73
- gem 'ffaker'
74
- ```
75
-
76
-
77
- ## RUN THE RSPEC INSTALLER
78
- - run `rails generate rspec:install`
79
-
80
- ## RUN HOT-GLUE INSTALL
81
- ### FOR ERB:
82
- `rails generate hot_glue:install --markup=erb`
83
-
84
- ### FOR HAML:
85
- `rails generate hot_glue:install --markup=haml`
86
-
87
-
88
- ## FOR RAILS 6 ONLY: SWITCH FROM TurblLinks to Turbo-Rails (SKIP THIS STEP FOR RAILS 7)
89
- (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION -- CONFIRM CHANGES ONLY)
90
- - Add `gem 'turbo-rails'` to your Gemfile & `bundle install`
91
- - Then install it with `rails turbo:install`
92
- - The Turbo install has switched your action cable settings from 'async' to Redis, so be sure to start a redis server
93
- - in `app/javascript/packs/application.js` remove this line
94
- ```
95
- import Turbolinks from "turbolinks"
96
- ```
97
- and replace it with
98
- ```
99
- import { Turbo } from "@hotwired/turbo-rails"
100
- ```
101
-
102
-
103
- Also replace
104
- ```
105
- Turbolinks.start()
106
- ```
107
- with:
108
- ```
109
- Turbo.start()
110
- ```
111
-
112
-
113
- ## Modify `application.html.erb`
114
- (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION -- CONFIRM CHANGES ONLY)
115
- Note: if you have some kind of non-standard application layout, like one at a different file
116
- or if you have modified your opening <body> tag, this may not have been automatically applied by the installer.
117
-
118
- - This was added to your `application.html.erb`
119
- ```
120
- <%= render partial: 'layouts/flash_notices' %>
121
- ```
122
-
123
- ## Modify `rails_helper.rb`
124
- (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION)
125
- Note: if you have some kind of non-standard rails_helper.rb, like one that does not use the standard ` do |config|` syntax after your `RSpec.configure`
126
- this may not have been automatically applied by the installer.
127
-
128
- - configure Rspec to work with Factory Bot inside of `rails_helper.rb`
129
- ```
130
- RSpec.configure do |config|
131
- // ... more rspec configuration (not shown)
132
- config.include FactoryBot::Syntax::Methods
133
- end
134
- ```
135
-
136
-
137
- ## CAPYBARA: SWITCH FROM RACK-TEST TO HEADLESS CHROME
138
- (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION)
139
-
140
- - By default Capybara is installed with :rack_test as its driver.
141
- - This does not support Javascript, and the code from Hot Glue IS NOT fallback compatible-- it will not work on non-Javascript browsers.
142
- - From the [Capybara docs](https://github.com/teamcapybara/capybara#drivers):
143
- ```
144
- By default, Capybara uses the :rack_test driver, which is fast but limited: it does not support JavaScript
145
- ```
146
-
147
- - To fix this, you must switch to a Javascript-supporting Capybara driver. You can choose one of:
148
- -
149
- ```
150
- Capybara.default_driver = :selenium
151
- ```
152
-
153
- ```
154
- Capybara.default_driver = :selenium_chrome
155
- ```
156
- By default, the installer should have added this option to your `rails_helper.rb` file:
157
-
158
- ```
159
- Capybara.default_driver = :selenium_chrome_headless
160
- ```
161
-
162
- Alternatively, can define your own driver like so:
163
-
164
- ```
165
- Capybara.register_driver :my_headless_chrome_desktop do |app|
166
- options = Selenium::WebDriver::Chrome::Options.new
167
- options.add_argument('--headless')
168
- options.add_argument('--disable-gpu')
169
- options.add_argument('--window-size=1280,1200')
170
-
171
- driver = Capybara::Selenium::Driver.new(app,
172
- browser: :chrome,
173
- options: options)
174
-
175
- driver
176
- end
177
- Capybara.default_driver = :my_headless_chrome_desktop
178
-
179
- ```
180
-
181
- ## Add User Authentication if you are using Access Control
182
- (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION)
183
-
184
- - for a quick Capybara login, create a support helper in `spec/support/` and log-in as your user
185
- - in the default code, the devise login would be for an object called account and lives at the route `/accounts/sign_in`
186
- - modify the generated code (it was installed by the installed) for your devise login
187
- ```
188
- def login_as(account)
189
- visit '/accounts/sign_in'
190
- within("#new_account") do
191
- fill_in 'Email', with: account.email
192
- fill_in 'Password', with: 'password'
193
- end
194
- click_button 'Log in'
195
- end
196
- ```
197
-
198
- ## Install Bootstrap using Sprockets (IMPORTANT: YOU DO NOT NEED JQUERY)
199
-
200
- Bootstrap with Sprockets for Rails 5 or 7 default — Rails 6 custom
201
- - add `gem 'bootstrap-rubygem'` to your gemfile
202
- - replace `application.css` with a new file (delete old contents) `application.scss`
203
- ```
204
- @import "bootstrap";
205
- ```
206
- - see README at github.com/twbs/bootstrap-rubygem to install
207
-
208
-
209
- ## Bootstrap with Webpack for FOR RAILS 7 ONLY :
210
- - add to Gemfile
211
- - gem 'bootstrap', '~> 5.1.0'
212
- - completely delete the file `app/assets/application.css`
213
- - create new file where it was `app/assets/application.scss` with this contents (do not keep the contents of the old application.css file):
214
- ```
215
- // Custom bootstrap variables must be set or imported *before* bootstrap.
216
- @import "bootstrap";
217
- ```
218
-
219
- * You do not need jQuery for HotGlue to work *
220
-
221
- ## Bootstrap with Webpack RAILS 6 ONLY:
222
- - change `stylesheet_link_tag` to `stylesheet_pack_tag` in your application layout
223
- - run `yarn add bootstrap`
224
- - create a new file at `app/javascript/require_bootstrap.scss` with this content
225
- ```
226
- @import "~bootstrap/scss/bootstrap.scss";
227
- ```
228
-
229
- - add to `app/javascript/packs/application.js`
230
- ```
231
- import 'require_bootstrap'
232
- ```
233
-
234
- ## RAILS 6 ONLY : Install Devise or implement your own authentication
235
- (or only use --gd mode, see below)
236
-
237
- Add to your Gemfile `gem 'devise'`
238
-
239
- ```
240
- rails generate devise:install
241
- ```
242
-
243
- IMPORTNAT: Follow the instructions the Devise installer gives you, *Except Step 3*, you can skip this step:
244
- ```
245
- 3. Ensure you have flash messages in app/views/layouts/application.html.erb.
246
- For example:
247
-
248
- <p class="notice"><%= notice %></p>
249
- <p class="alert"><%= alert %></p>
250
-
251
- ```
252
-
253
-
254
- You can also skip Devise Step 4, which is optional:
255
- ```
256
- 4. You can copy Devise views (for customization) to your app by running:
257
-
258
- rails g devise:views
259
-
260
- * Not required *
261
- ```
262
-
263
-
264
- ## RAILS 7: Devise is not yet supported on Rails 7
265
-
266
-
267
- ## install font-awesome
268
-
269
- I recommend https://github.com/tomkra/font_awesome5_rails
270
- or https://github.com/FortAwesome/font-awesome-sass
271
-
272
-
273
-
274
- ## For Enum support, I recommend activerecord-pgenum
275
-
276
- Instructions for Rails are here:
277
- https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
278
-
279
-
280
-
281
-
282
- ### First Argument
283
- (no double slash)
284
-
285
- TitleCase class name of the thing you want to build a scaffoling for.
286
-
287
-
288
- ## Options With Arguments
289
-
290
- All options two dashes (--) and these take an `=` and a value
291
-
292
- ### `--namespace=`
293
-
294
- pass `--namespace=` as an option to denote a namespace to apply to the Rails path helpers
295
-
296
-
297
- `rails generate hot_glue:scaffold Thing --namespace=dashboard`
298
-
299
- This produces several views at `app/views/dashboard/things/` and a controller at`app/controllers/dashboard/things_controller.rb`
300
-
301
- The controller looks like so:
302
-
303
- ```
304
- class Dashboard::ThingsController < ApplicationController
305
- before_action :authenticate_user!
306
- before_action :load_thing, only: [:show, :edit, :update, :destroy]
307
- def load_thing
308
- @thing = current_user.things.find(params[:id])
309
- end
310
- ...
311
- end
312
-
313
- ```
314
-
315
-
316
- ### `--nest=`
317
-
318
- pass `--nest=` to denote a nested resources
319
-
320
-
321
- `rails generate hot_glue:scaffold Line --nest=invoice`
322
-
323
- In this example, it is presumed that the current user has_many :invoices, and that invoices have many :lines
324
-
325
-
326
- For multi-level nesting use slashes to separate your levels of nesting. Remember, you should match what you have in your routes.rb file.
327
-
328
- ```
329
- resources :invoices do
330
- resources :lines do
331
- resources :charge
332
- end
333
- end
334
-
335
- ```
336
- In this example, it is presumed that the current user has_many :invoices, and that invoices have many :lines, and that lines have many :charges
337
-
338
-
339
- To generate scaffold:
340
- `rails generate hot_glue:scaffold Charge --nest=invoice/line`
341
-
342
- The order of the nest should match the nested resources you have in your own app. In particular, you auth root will be used as the starting point when loading the objects from the URL:
343
-
344
- In the example above, @invoice will be loaded from
345
-
346
- `@invoice = current_user.invoices.find(params[:invoice_id])`
347
-
348
- Then, @line will be loaded
349
-
350
- `@line = @invoice.lines.find(params[:line_id])`
351
-
352
- Then, finally the @charge will be loaded
353
-
354
- `@charge = @line.charges.find(params[:id])`
355
-
356
- It's called "poor man's access control" because if a user attempts to hack the URL by passing ids for objects they don't own--- which Rails makes relatively easy with its default URL pattern-- they will hit ActiveRecord not found errors (the objects they don't own won't be found in the associated relationship).
357
-
358
- It works, but it isn't granular. As well, it isn't appropriate for a large app with any level of intricacy to access control (that is, having roles).
359
-
360
- Your customers can delete their own objects by default (may be a good idea or a bad idea for you). If you don't want that, you should strip out the delete actions off the controllers.
361
-
362
-
363
- ### `--auth=`
364
-
365
- By default, it will be assumed you have a `current_user` for your user authentication. This will be treated as the "authentication root" for the "poor man's auth" explained above.
366
-
367
- The poor man's auth presumes that object graphs have only one natural way to traverse them (that is, one primary way to traverse them), and that all relationships infer that a set of things or their descendants are granted access to me for reading, writing, updating, and deleting.
368
-
369
- Of course this is a sloppy way to do access control, and can easily leave open endpoints your real users shouldn't have access to.
370
-
371
- When you display anything built with the scaffolding, we assume the `current_user` will have `has_many` association that matches the pluralized name of the scaffold. In the case of nesting, we will automatically find the nested objects first, then continue down the nest chain to find the target object. In this way, we know that all object are 'anchored' to the logged-in user.
372
-
373
- If you use Devise, you probably already have a `current_user` method available in your controllers. If you don't use Devise, you can implement it in your ApplicationController.
374
-
375
- If you use a different object other than "User" for authentication, override using the `auth` option.
376
-
377
- `rails generate hot_glue:scaffold Thing --auth=current_account`
378
-
379
- You will note that in this example it is presumed that the Account object will have an association for `things`
380
-
381
- It is also presumed that when viewing their own dashboard of things, the user will want to see ALL of their associated things.
382
-
383
- If you supply nesting (see below), your nest chain will automatically begin with your auth root object (see nesting)
384
-
385
-
386
-
387
-
388
- ### `--auth_identifier=`
389
-
390
- Your controller will call a method authenticate_ (AUTH IDENTIFIER) bang, like:
391
-
392
- `authenticate_user!`
393
-
394
- Before all of the controller actions. If you leave this blank, it will default to using the variable name supplied by auth with "current_" stripped away.
395
- (This is setup for devise.)
396
-
397
- Be sure to implement the following method in your ApplicationController or some other method. Here's a quick example using Devise. You will note in the code below, user_signed_in? is implemented when you add Devise methods to your User table.
398
-
399
- As well, the `after_sign_in_path_for(user)` here is a hook for Devise also that provides you with after login redirect to the page where the user first intended to go.
400
-
401
- ```
402
- def authenticate_user!
403
- if ! user_signed_in?
404
- session['user_return_to'] = request.path
405
- redirect_to new_user_registration_path
406
- end
407
- end
408
-
409
- def after_sign_in_path_for(user)
410
- session['user_return_to'] || account_url(user)
411
- end
412
- ```
413
-
414
-
415
- The default (do not pass `auth_identifier=`) will match the `auth` (So if you use 'account' as the auth, `authenticate_account!` will get invoked from your generated controller; the default is always 'user', so you can leave both auth and auth_identifier off if you want 'user')
416
-
417
-
418
- `rails generate hot_glue:scaffold Thing --auth=current_account --auth_identifier=login`
419
- In this example, the controller produced with:
420
- ```
421
- before_action :authenticate_login!
422
- ```
423
- However, the object graph anchors would continue to start from current_account. That is,
424
- ```
425
- @thing = current_account.things.find(params[:id])
426
- ```
427
-
428
- Use empty string to **turn this method off**:
429
- `rails generate hot_glue:scaffold Thing --auth=current_account --auth_identifier=''`
430
-
431
- In this case a controller would be generated that would have NO before_action to authenticate the account, but it would still treat the current_account as the auth root for the purpose of loading the objects.
432
-
433
- Please note that this example would product non-functional code, so you would need to manually fix your controllers to make sure `current_account` is available to the controller.
434
-
435
-
436
- ### `--plural=`
437
-
438
- You don't need this if the pluralized version is just + "s" of the singular version. Only use for non-standard plurlizations, and be sure to pass it as TitleCase (as if you pluralized the model name which is non-standard for Rails)
439
-
440
-
441
- ### `--exclude=`
442
- (separate field names by COMMA)
443
-
444
- By default, all fields are included unless they are on the exclude list. (The default for the exclude list is `id`, `created_at`, and `updated_at` so you don't need to exclude those-- they are added.)
445
-
446
- If you specify an exclude list, those and the default excluded list will be excluded.
447
-
448
-
449
- `rails generate hot_glue:scaffold Account --exclude=password`
450
-
451
- (The default excluded list is: :id, :created_at, :updated_at, :encrypted_password, :reset_password_token, :reset_password_sent_at, :remember_created_at, :confirmation_token, :confirmed_at, :confirmation_sent_at, :unconfirmed_email. If you want to edit any fields with the same name, you must use the include flag instead.)
452
-
453
-
454
- ### `--include=`
455
- (separate field names by COMMA)
456
-
457
- You may not specify both include and exclude. If you specify an include list, it will be treated as a whitelist: no fields will be included unless specified on the include list.
458
-
459
- `rails generate hot_glue:scaffold Account --include=first_name,last_name,company_name,created_at,kyc_verified_at`
460
-
461
-
462
- ### `--show-only=`
463
- (separate field names by COMMA)
464
-
465
- Any fields only the 'show-only' list will appear as non-editable on the generate form. (visible only)
466
-
467
- IMPORTANT: By default, all fields that begin with an underscore (`_`) are automatically show-only.
468
-
469
- I would recommend this for fields you want globally non-editable by users in your app. For example, a counter cache or other field set only by a backend mechanism.
470
-
471
- ### `--stimulus_syntax=true` or `--stimulus_syntax=false`
472
- (for Rails <=6, default is false. For Rails 7, default is true.)
473
-
474
- Stimulus is only used for the delete button's confirmation dialog.
475
-
476
- If you don't have stimulus syntax enabled, your delete buttons have this. This will confirm the delete with a simple alert if you have UJS enabled.
477
-
478
- ```
479
- {confirm: 'Are you sure?'}
480
- ```
481
-
482
- If you do have Stimulus syntax enabled, your delete buttons will look like so:
483
- ```
484
- <%= button_to "Delete <i class='fa fa-1x fa-remove'></i>".html_safe,
485
- thing_path(branch), method: :delete,
486
- data: {
487
- 'controller: 'confirmable',
488
- 'confirm-message': 'Are you sure you want to delete Thing?',
489
- 'action': 'confirmation#confirm'
490
- },
491
- disable_with: "Loading...", class: "delete-branch-button btn btn-primary " %>
492
- ```
493
-
494
- Your install script will output an additional stimulus controller:
495
-
496
- ```
497
-
498
- ```
499
-
500
-
501
-
502
- ### `--markup` (default: 'erb')
503
-
504
- ERB is default. For HAML, `--markup=haml`.
505
-
506
-
507
- ## FLAGS (Options with no values)
508
- These options (flags) also uses `--` syntax but do not take any values. Everything is assumed (default) to be false unless specified.
509
-
510
- ### `--god` or `--gd`
511
-
512
- Use this flag to create controllers with no root authentication. You can still use an auth_identifier, which can be useful for a meta-leval authentication to the controller.
513
-
514
- For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use `--god` flag.
515
-
516
- In Gd mode, the objects are loaded directly from the base class (these controllers have full access)
517
- ```
518
- def load_thing
519
- @thing = Thing.find(params[:id])
520
- end
521
-
522
- ```
523
-
524
-
525
- ### `--specs-only`
526
-
527
- Produces ONLY the controller spec file, nothing else.
528
-
529
-
530
- ### `--no-specs`
531
-
532
- Produces all the files except the spec file.
533
-
534
-
535
- ### `--no-paginate`
536
-
537
- Omits pagination. (All list views have pagination by default.)
538
-
539
-
540
- ### `--no-create`
541
-
542
- Omits create action.
543
-
544
- ### `--no-delete`
545
-
546
- Omits delete action.
547
-
548
- ### `--big-edit`
549
-
550
- If you do not want inline editing of your list items but instead to fall back to full page style behavior for your edit views, use `--big-edit`. Turbo still handles the page interactions, but the user is taken to a full-screen edit page instead of an edit-in-place interaction.
551
-
552
-
553
- ## Automatic Base Controller
554
-
555
- HotGlue will copy a file named base_controller.rb to the same folder where it tries to create any controller, unless such a file exists there already.
556
-
557
- Obviously, the created controller will always have this base controller as its subclass. In this way, you are encouraged to implement functionality common to the *namespace* (shared between the controllers in the namespace), using this technique.
558
-
559
- ## Field Types Supported
560
-
561
- - Integers that don't end with `_id`, they will be displayed as text fields.
562
- - Integers that do end with `_id` will be treated automatically as associations. You should have a Rails association defined. (Hot Glue will warn you if it can't find one.)
563
- - String*
564
- - Text*
565
- - Float*
566
- - Datetime
567
- - Date (TOOD: implement this)
568
- - Time (TOOD: implement this)
569
- - Boolean
570
- - Enum - will be magically displayed as a value list populated from the enum list defined on your model. see https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
571
-
572
- * shows in a size-aware container, i.e. in a bigger box if the field allows for more content
573
-
574
-
575
-
576
- # VERSION HISTORY
577
-
578
- #### 2021-10-11 - v0.2.6 - many additional automatic fixes for default Rails installation 6 or 7 for the generate hot_glue:install command
579
-
580
-
581
- #### 2021-10-10 - v0.2.5 - this version is all about developer happyness:
582
- - significant fixes for the behavioral (system) specs. they now create new & update interactions
583
- for (almost) all field types
584
- - the install generator now checks your layouts/application.html.erb for `render partial: 'layouts/flash_messages' ` and adds it if it isn't there already
585
- - the install generator also checks your spec/rails_helper for `config.include FactoryBot::Syntax::Methods` and adds it at the top of the Rspec configure block if it isn't there
586
-
587
- #### 2021-10-07 - v0.2.4 - removes erroneous icons display in delete buttos (these don't work inside of button_to);
588
- - adds support for ENUM types direclty on your field types
589
- - you must use activerecord-pgenum
590
- - see my blog post at https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
591
-
592
- #### 2021-09-30 - v0.2.3 - fixes ERB output for show-only fields; fixes flash_notices for erb or haml; adds @stimulus_syntax flag for delete confirmations with stimulus
593
-
594
- #### 2021-09-27 - v0.2.2 - Fixes some issues with related fields; unlocks Rails 7 in Gemspec file
595
-
596
- #### 2021-09-20 - v0.2.1 - Fixes nesting behavior when using gd option
597
-
598
- #### 2021-09-06 - v0.2.0 - ERB or HAML; use the option --markup=erb or --markup=haml (default is now erb)
599
-
600
- #### 2021-06-28 - v0.1.2 - fixes problem with namespaces on path helpers
601
-
602
- #### 2021-05-09 (yanked) - v0.1.1 - add cancellation buttons
603
-
604
- #### 2021-04-28 - v0.1.0 - Very pleased to introduce full behavior specs, found in specs/system/, generated by default on all build code; also many fixes involving nesting and authentication"
605
-
606
- #### 2021-03-24 - v0.0.9 - fixes in the automatic field label detection; cleans up junk in spec output
607
-
608
- #### 2021-03-21 - v0.0.8 - show only flag; more specific spec coverage in generator spec
609
-
610
- #### 2021-03-20 - v0.0.7 - adds lots of spec coverage; cleans up generated cruft code on each run; adds no-delete, no-create; a working --big-edit with basic data-turbo false to disable inline editing
611
-
612
- #### 2021-03-06 - v0.0.6 - internal specs test the error catches and cover basic code generation (dummy testing only)
613
-
614
- #### 2021-03-01 - v0.0.5 - Validation magic; refactors the options to the correct Rails::Generators syntax
615
-
616
- #### (yanked) - v0.0.4
617
-
618
- #### 2021-02-27 - v0.0.3 - several fixes for namespaces; adds pagination; adds exclude list to fields
619
-
620
- #### 2021-02-25 - v0.0.2 - bootstrapy
621
-
622
- #### 2021-02-24 - v0.0.1 - first proof of concept release -- basic CRUD works
623
-
624
- #### 2021-02-23 - v0.0.0 - Port of my prior work from github.com/jasonfb/common_core_js
625
-
626
-
627
-
628
- # HOW THIS GEM IS TESTED
629
-
630
- SETUP:
631
- • Run bundle install
632
- • if you can't get through see https://stackoverflow.com/questions/68050807/gem-install-mimemagic-v-0-3-10-fails-to-install-on-big-sur/68170982#68170982
633
-
634
-
635
- The dummy sandbox is found at `spec/dummy`
636
-
637
- The dummy sandbox lives as mostly checked- into the repository, **except** the folders where the generated code goes (`spec/dummy/app/views/`, `spec/dummy/app/controllers/`, `spec/dummy/specs/` are excluded from Git)
638
-
639
- When you run the **internal specs**, which you can do **at the root of this repo** using the command `rspec`, a set of specs will run to assert the generators are erroring when they are supposed to and producing code when they are supposed to.
640
-
641
- The DUMMY testing DOES NOT test the actual functionality of the output code (it just tests the functionality of the generation process).
642
-
@@ -61,7 +61,8 @@ module HotGlue
61
61
  # elsif self.class.ancestors.include?(ApplicationController)
62
62
  # self.try(:current_timezone)
63
63
  else
64
- raise "no method current_user is available; please implement/override the method current_timezone IN YOUR CONTROLLER"
64
+ puts "no method current_user is available; please implement/override the method current_timezone IN YOUR CONTROLLER"
65
+ exit
65
66
  end
66
67
  end
67
68