hot-glue 0.2.3 → 0.2.9E

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -1
  3. data/.travis.yml +15 -0
  4. data/Gemfile +8 -2
  5. data/Gemfile.lock +35 -24
  6. data/README.md +307 -85
  7. data/Rakefile +34 -24
  8. data/app/helpers/hot_glue/controller_helper.rb +6 -4
  9. data/app/helpers/hot_glue_helper.rb +4 -0
  10. data/app/views/layouts/_flash_notices.erb +12 -0
  11. data/lib/generators/hot_glue/install_generator.rb +55 -0
  12. data/lib/generators/hot_glue/markup_templates/erb.rb +51 -8
  13. data/lib/generators/hot_glue/markup_templates/haml.rb +2 -2
  14. data/lib/generators/hot_glue/scaffold_generator.rb +87 -35
  15. data/lib/generators/hot_glue/templates/capybara_login.rb +8 -0
  16. data/lib/generators/hot_glue/templates/confirmable.js +14 -0
  17. data/lib/generators/hot_glue/templates/controller.rb.erb +18 -22
  18. data/lib/generators/hot_glue/templates/erb/_line.erb +1 -1
  19. data/lib/generators/hot_glue/templates/erb/_list.erb +10 -2
  20. data/lib/generators/hot_glue/templates/erb/_show.erb +18 -2
  21. data/lib/generators/hot_glue/templates/erb/create.turbo_stream.erb +3 -3
  22. data/lib/generators/hot_glue/templates/erb/destroy.turbo_stream.erb +1 -1
  23. data/lib/generators/hot_glue/templates/erb/edit.erb +3 -13
  24. data/lib/generators/hot_glue/templates/erb/index.erb +1 -2
  25. data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +5 -2
  26. data/lib/generators/hot_glue/templates/haml/_line.haml +1 -1
  27. data/lib/generators/hot_glue/templates/haml/_list.haml +5 -1
  28. data/lib/generators/hot_glue/templates/haml/create.turbo_stream.haml +3 -3
  29. data/lib/generators/hot_glue/templates/haml/destroy.turbo_stream.haml +1 -1
  30. data/lib/generators/hot_glue/templates/haml/edit.haml +0 -2
  31. data/lib/generators/hot_glue/templates/haml/index.haml +1 -2
  32. data/lib/generators/hot_glue/templates/system_spec.rb.erb +146 -47
  33. data/lib/hot-glue.rb +1 -2
  34. data/lib/hotglue/version.rb +1 -1
  35. metadata +23 -33
data/README.md CHANGED
@@ -1,7 +1,17 @@
1
1
 
2
+ [![Build Status](https://app.travis-ci.com/jasonfb/hot-glue.svg?branch=main)](https://travis-ci.com/jasonfb/hot-glue)
3
+
4
+
2
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)).
3
6
 
4
- Using Turbo-Rails and Hotwire you get a lightning-fast out-of-the-box CRUD building experience. Every page displays only a list view: new and edit operations happen as 'edit-in-place', so the user never leaves the page.
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.
5
15
 
6
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.
7
17
 
@@ -9,25 +19,19 @@ By default, it generates code that gives users full control over objects they 'o
9
19
 
10
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.
11
21
 
12
- * Build plug-and-play scaffolding for any CRUD on any object
13
- * mixes HAML and turbo_stream responses
14
- * Everything edits-in-place (unless you use --big-edit, then it won't)
15
- * Automatically reads your ActiveRecord models and relationships (make them before building your scaffolding!)
16
- * Create-read-update-delete (CRUD) with pagination (one day: sorting & searching)
17
- * Excellent tool for prototyping and hackathons, but a knowledge of Rails is needed.
18
- * Nest your routes model-by-model for built-in poor man's authentication. (Customers have_many :invoices; Invoices have_many :line_items; etc)
19
- * Plays nicely with Devise, but you can implement your own current_user object instead.
20
- * Kaminari for pagination.
21
- * Create specs automatically along with the controllers.
22
- * Throw the scaffolding away when your app is ready to graduate to its next phase (or don't if you like it).
22
+ * Build plug-and-play scaffolding mixing generated ERB or HAML with the power of Hotwire and Turbo-Rails
23
+ * Everything edits-in-place (unless you use --big-edit, then it won't)
24
+ * Automatically Reads Your Models (make them before building your scaffolding!)
25
+ * Excellent for CREATE-READ-UPDATE-DELETE (CRUD), lists with pagination (coming soon: searching & sorting)
26
+ * Great for prototyping, but you should learn Rails fundamentals first.
27
+ * 'Packaged' with Devise, Kaminari, Rspec, FontAwesome
28
+ * Create system specs automatically along with the generated code.
29
+ * Nest your routes model-by-model for built-in poor man's authentication.
30
+ * Throw the scaffolding away when your app is ready to graduate to its next phase.
23
31
 
24
32
  ## QUICK START
25
33
 
26
- It's really easy to get started by following along with this blog post that creates three simple tables (User, Event, and Format).
27
-
28
- Feel free to build your own tables when you get to the sections for building the 'Event' scaffold:
29
-
30
- https://jasonfleetwoodboldt.com/hot-glue
34
+ If you like tutorials, try https://jasonfleetwoodboldt.com/hot-glue
31
35
 
32
36
  ## HOW EASY?
33
37
 
@@ -44,88 +48,141 @@ Instantly get a simple CRUD interface
44
48
 
45
49
  ![hot-glue-4](https://user-images.githubusercontent.com/59002/116405517-c2b2e300-a7fd-11eb-8423-d43e3afc9fa6.gif)
46
50
 
47
- ## TO INSTALL (RAILS 7)
51
+ # Getting Started
48
52
 
49
- - Install Turbo `rails turbo:install` (?)
53
+ ## 1. ADD HOTWIRE
54
+ (RAILS 6 ONLY— SKIP THIS STEP FOR RAILS 7)
55
+ ```
56
+ yarn add @hotwired/turbo-rails
57
+ ```
58
+ or `npm install @hotwired/turbo-rails`
50
59
 
51
- - Add `gem 'hot-glue'` to your Gemfile & `bundle install`
52
- `rails generate hot_glue:install --markup=erb`
53
60
 
54
- - Add to your `application.html.erb`
61
+ ## 2. SWITCH FROM TurblLinks to Turbo-Rails
62
+ (RAILS 6 ONLY— SKIP THIS STEP FOR RAILS 7)
63
+ (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION -- CONFIRM CHANGES ONLY)
64
+ - Add `gem 'turbo-rails'` to your Gemfile & `bundle install`
65
+ - Then install it with `rails turbo:install`
66
+ - The Turbo install has switched your action cable settings from 'async' to Redis, so be sure to start a redis server
67
+ - in `app/javascript/packs/application.js` remove this line
55
68
  ```
56
- <%= render partial: 'layouts/flash_notices' %>
69
+ import Turbolinks from "turbolinks"
70
+ ```
71
+ and replace it with
72
+ ```
73
+ import { Turbo } from "@hotwired/turbo-rails"
57
74
  ```
58
75
 
59
76
 
60
- ## TO INSTALL (RAILS 6)
77
+ Also replace
78
+ ```
79
+ Turbolinks.start()
80
+ ```
81
+ with:
82
+ ```
83
+ Turbo.start()
84
+ ```
61
85
 
62
- - Add `gem 'turbo-rails'` to your Gemfile & `bundle install`
63
-
64
- - Then install it with `rails turbo:install`
65
86
 
66
- - The Turbo install has switched your action cable settings from 'async' to Redis, so be sure to start a redis server
67
-
68
- - Add `gem 'hot-glue'` to your Gemfile & `bundle install`
69
-
70
- - in `javascript/packs/application.js` remove this line:
71
- `import Turbolinks from "turbolinks"`
87
+ ## 3. ADD HOT-GLUE GEM
88
+ - Add `gem 'hot-glue', '~> 0.2.6'` to your Gemfile & `bundle install`
89
+
90
+ (TODO: figure out why bundler seems to install the yanked version 0.0.0 if you don't specify the hot glue version)
91
+
92
+ ## 4. ADD RSPEC, FACTORY-BOT, AND FFAKER
72
93
 
73
- - in the same file (`javascript/packs/application.js`) add this line:
74
- `import { Turbo } from "@hotwired/turbo-rails"`
94
+ add these 3 gems to your gemfile **inside a group for both :development and :test*. Do not add these gems to only the :test group or else your will have problems with the generators.
95
+ ```
96
+ gem 'rspec-rails'
97
+ gem 'factory_bot_rails'
98
+ gem 'ffaker'
99
+ ```
75
100
 
76
- - Run the hot-glue install generator
101
+ - run `rails generate rspec:install`
77
102
 
78
- FOR ERB:
103
+ ## 5(A). RUN HOT-GLUE INSTALL
104
+ ### FOR ERB:
79
105
  `rails generate hot_glue:install --markup=erb`
80
106
 
81
- FOR HAML:
107
+ ### FOR HAML:
82
108
  `rails generate hot_glue:install --markup=haml`
83
109
 
84
- - Add to your `application.html.erb`
110
+
111
+
112
+
113
+
114
+ ## 5(B). Modify `application.html.erb`
115
+ (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION -- CONFIRM CHANGES ONLY)
116
+ Note: if you have some kind of non-standard application layout, like one at a different file
117
+ or if you have modified your opening <body> tag, this may not have been automatically applied by the installer.
118
+
119
+ - This was added to your `application.html.erb`
85
120
  ```
86
121
  <%= render partial: 'layouts/flash_notices' %>
87
122
  ```
88
123
 
124
+ ## 5(C). Modify `rails_helper.rb`
125
+ (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION)
126
+ 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`
127
+ this may not have been automatically applied by the installer.
89
128
 
90
- ## Rspec setup
91
- - add `gem 'rspec-rails'` to your gemfile inside :development and :test
92
- - add `gem 'factory_bot_rails'` to your gemfile inside :development and :test
93
- - run `rails generate rspec:install`
94
- - configure Rspec to work with Factory Bot inside of `rails_helper.rb`
95
- ```
96
- RSpec.configure do |config|
97
- // ... more rspec configuration (not shown)
98
- config.include FactoryBot::Syntax::Methods
99
- end
100
- ```
101
- more info:
102
- https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#rspec
129
+ - configure Rspec to work with Factory Bot inside of `rails_helper.rb`
130
+ ```
131
+ RSpec.configure do |config|
132
+ // ... more rspec configuration (not shown)
133
+ config.include FactoryBot::Syntax::Methods
134
+ end
135
+ ```
103
136
 
104
- - for a quick Capybara login, create a support helper in `spec/support/` and log-in as your user
105
- ```
106
- def login_as(account)
107
- visit '/accounts/sign_in'
108
- within("#new_account") do
109
- fill_in 'Email', with: account.email
110
- fill_in 'Password', with: 'password'
111
- end
112
- click_button 'Log in'
113
- end
114
- ```
115
137
 
116
- ## Install Bootstrap using Sprockets (IMPORTANT: YOU DO NOT NEED JQUERY*)
117
- - Bootstrap with Sprockets for Rails 5 or 7 default — Rails 6 custom
118
- - use twbs/bootstrap-rubygem gem
119
- - see README for bootstrap-rubygem to install
120
- - Bootstrap with Webpack for FOR RAILS 7 :
121
-
122
- - add to Gemfile
123
- - gem 'bootstrap', '~> 5.1.0'
138
+ ## 5(D) CAPYBARA: SWITCH FROM RACK-TEST TO HEADLESS CHROME
139
+ (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION)
140
+
141
+ - By default Capybara is installed with :rack_test as its driver.
142
+ - This does not support Javascript, and the code from Hot Glue IS NOT fallback compatible-- it will not work on non-Javascript browsers.
143
+ - From the [Capybara docs](https://github.com/teamcapybara/capybara#drivers):
144
+ ```
145
+ By default, Capybara uses the :rack_test driver, which is fast but limited: it does not support JavaScript
146
+ ```
147
+
148
+ - To fix this, you must switch to a Javascript-supporting Capybara driver. You can choose one of:
149
+
150
+ `Capybara.default_driver = :selenium`
151
+ `Capybara.default_driver = :selenium_chrome`
152
+ `Capybara.default_driver = :selenium_chrome_headless`
153
+
154
+ By default, the installer should have added this option to your `rails_helper.rb` file:
155
+
156
+ ```
157
+ Capybara.default_driver = :selenium_chrome_headless
158
+ ```
159
+
160
+ Alternatively, can define your own driver like so:
124
161
 
162
+ ```
163
+ Capybara.register_driver :my_headless_chrome_desktop do |app|
164
+ options = Selenium::WebDriver::Chrome::Options.new
165
+ options.add_argument('--headless')
166
+ options.add_argument('--disable-gpu')
167
+ options.add_argument('--window-size=1280,1200')
168
+
169
+ driver = Capybara::Selenium::Driver.new(app,
170
+ browser: :chrome,
171
+ options: options)
172
+
173
+ driver
174
+ end
175
+ Capybara.default_driver = :my_headless_chrome_desktop
176
+
177
+ ```
125
178
 
179
+
180
+ ### 6(A) Bootstrap with Webpack:
181
+ DO EIETHER 6(A) OR 6(B)
182
+ - add to Gemfile
183
+ - `gem 'bootstrap', '~> 5.1.3'`
126
184
  - completely delete the file `app/assets/application.css`
127
185
  - create new file where it was `app/assets/application.scss` with this contents (do not keep the contents of the old application.css file):
128
-
129
186
  ```
130
187
  // Custom bootstrap variables must be set or imported *before* bootstrap.
131
188
  @import "bootstrap";
@@ -133,7 +190,7 @@ FOR HAML:
133
190
 
134
191
  * You do not need jQuery for HotGlue to work *
135
192
 
136
- ### Bootstrap with Webpack RAILS 6 ONLY:
193
+ ### Hook your Bootstrap into your global application scss
137
194
  - change `stylesheet_link_tag` to `stylesheet_pack_tag` in your application layout
138
195
  - run `yarn add bootstrap`
139
196
  - create a new file at `app/javascript/require_bootstrap.scss` with this content
@@ -145,17 +202,95 @@ FOR HAML:
145
202
  ```
146
203
  import 'require_bootstrap'
147
204
  ```
148
-
149
205
 
150
206
 
207
+ ## 6(B) Install Bootstrap using Sprockets
208
+ (IMPORTANT: YOU DO NOT NEED JQUERY)
209
+ DO EIETHER 6(A) OR 6(B)
210
+
211
+ Bootstrap with Sprockets for Rails 5 or 7 default — Rails 6 custom
212
+ - add `gem 'bootstrap-rubygem'` to your gemfile
213
+ - replace `application.css` with a new file (delete old contents) `application.scss`
214
+ ```
215
+ @import "bootstrap";
216
+ ```
217
+ - see README at github.com/twbs/bootstrap-rubygem to install
218
+
219
+
220
+
221
+
222
+ ## 7. install font-awesome
223
+
224
+ I recommend https://github.com/tomkra/font_awesome5_rails
225
+ or https://github.com/FortAwesome/font-awesome-sass
151
226
 
152
- ## Install Devise or implement your own authentication
153
- (or only use --gd mode, see below)
154
227
 
155
- ## install font-awesome. I recommend https://github.com/tomkra/font_awesome5_rails or https://github.com/FortAwesome/font-awesome-sass
156
228
 
229
+ ## 8. For Enum support, I recommend activerecord-pg_enum
157
230
 
158
- ### First Argument
231
+ Instructions for Rails are here:
232
+ https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
233
+
234
+
235
+
236
+ ## 9. Devise
237
+ (or only use --gd mode, see below)
238
+
239
+ Add to your Gemfile `gem 'devise'`
240
+
241
+
242
+
243
+ ```
244
+ rails generate devise:install
245
+ ```
246
+
247
+ IMPORTANT: Follow the instructions the Devise installer gives you, *Except Step 3*, you can skip this step:
248
+ ```
249
+ 3. Ensure you have flash messages in app/views/layouts/application.html.erb.
250
+ For example:
251
+
252
+ <p class="notice"><%= notice %></p>
253
+ <p class="alert"><%= alert %></p>
254
+
255
+ ```
256
+
257
+
258
+ You can also skip Devise installer Step 4, which is optional:
259
+ ```
260
+ 4. You can copy Devise views (for customization) to your app by running:
261
+
262
+ rails g devise:views
263
+
264
+ * Not required *
265
+ ```
266
+
267
+
268
+ ## 9(B) Devise & Capybara - Add User Authentication if you are using Access Control
269
+ (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION)
270
+
271
+ - for a quick Capybara login, create a support helper in `spec/support/` and log-in as your user
272
+ - in the default code, the devise login would be for an object called account and lives at the route `/accounts/sign_in`
273
+ - modify the generated code (it was installed by the installed) for your devise login
274
+ ```
275
+ def login_as(account)
276
+ visit '/accounts/sign_in'
277
+ within("#new_account") do
278
+ fill_in 'Email', with: account.email
279
+ fill_in 'Password', with: 'password'
280
+ end
281
+ click_button 'Log in'
282
+ end
283
+ ```
284
+
285
+
286
+ ## RAILS 7: Devise is not yet supported on Rails 7 unless you use the master branch of devise
287
+
288
+
289
+
290
+ # HOT GLUE DOCS
291
+
292
+
293
+ ## First Argument
159
294
  (no double slash)
160
295
 
161
296
  TitleCase class name of the thing you want to build a scaffoling for.
@@ -229,7 +364,7 @@ Then, finally the @charge will be loaded
229
364
 
230
365
  `@charge = @line.charges.find(params[:id])`
231
366
 
232
- It's called "poor man's auth" 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).
367
+ 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).
233
368
 
234
369
  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).
235
370
 
@@ -242,7 +377,7 @@ By default, it will be assumed you have a `current_user` for your user authentic
242
377
 
243
378
  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.
244
379
 
245
- Of course this is a sloppy way to do authentication, and can easily leave open endpoints your real users shouldn't have access to.
380
+ 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.
246
381
 
247
382
  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.
248
383
 
@@ -344,9 +479,18 @@ IMPORTANT: By default, all fields that begin with an underscore (`_`) are automa
344
479
 
345
480
  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.
346
481
 
347
- ### `stimulus_syntax` (default is false for Rails <=6; true for Rails 7)
482
+ ### `--stimulus_syntax=true` or `--stimulus_syntax=false`
483
+ (for Rails <=6, default is false. For Rails 7, default is true.)
484
+
485
+ Stimulus is only used for the delete button's confirmation dialog.
486
+
487
+ 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.
348
488
 
349
- Your delete buttons will look like so:
489
+ ```
490
+ {confirm: 'Are you sure?'}
491
+ ```
492
+
493
+ If you do have Stimulus syntax enabled, your delete buttons will look like so:
350
494
  ```
351
495
  <%= button_to "Delete <i class='fa fa-1x fa-remove'></i>".html_safe,
352
496
  thing_path(branch), method: :delete,
@@ -356,8 +500,6 @@ Your delete buttons will look like so:
356
500
  'action': 'confirmation#confirm'
357
501
  },
358
502
  disable_with: "Loading...", class: "delete-branch-button btn btn-primary " %>
359
-
360
-
361
503
  ```
362
504
 
363
505
  Your install script will output an additional stimulus controller:
@@ -416,13 +558,79 @@ Omits delete action.
416
558
 
417
559
  ### `--big-edit`
418
560
 
419
- If you do not want inline editing of your list items but instead to fall back to old fashioned new page behavior for your edit views, use `--big-edit`.
561
+ 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.
562
+
563
+ ### `--display-list-after-update` (default: false)
564
+
565
+ After an update-in-place normally only the edit view is swapped out for the show view of the record you just edited.
566
+
567
+ Sometimes you might want to redisplay the entire list after you make an update (for example, if your action removes that record from the result set).
568
+
569
+ To do this, use flag `--display_list_after_update`. The update will behave like delete and re-fetch all the records in the result and tell Turbo to swap out the entire list.
570
+
571
+
572
+
573
+ ### `--downnest`
574
+ (2021-11-23 - WIP)
575
+
576
+ Automatically create subviews down your object tree. This should be the name of a has_many relationship based from the current object.
577
+ You will need to build scaffolding with the same name for the related object as well.
578
+ On the list view, the object you are currently building will be built with a sub-view list of the objects related from the given line.
579
+
580
+ ### `--nestable` (default: false)
581
+ (2021-11-23 - WIP)
582
+ When creating a controller that you will use a another controllers downnest (that is, you will display related records-- like a portal-- from the parent within each row of the parent's list view), set nestable to true.
583
+
584
+ If the cooresponding Rails route contains nesting and this controller is downnested by someone else, you'll want to set nestable to true.
585
+
586
+ If the cooresponding Rails route is not nested and the controller sits a the root of the namespace, set nestable to false.
587
+
588
+
589
+ ## Automatic Base Controller
420
590
 
591
+ 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.
421
592
 
593
+ 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.
594
+
595
+ ## Field Types Supported
596
+
597
+ - Integers that don't end with `_id`, they will be displayed as text fields.
598
+ - 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.)
599
+ - String*
600
+ - Text*
601
+ - Float*
602
+ - Datetime
603
+ - Date
604
+ - Time
605
+ - Boolean
606
+ - Enum - will display 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/
607
+
608
+ * shows in a size-aware container, i.e. in a bigger box if the field allows for more content
422
609
 
423
610
 
424
611
 
425
612
  # VERSION HISTORY
613
+
614
+ #### 2021-11-27 - v0.2.9E — EXPERIMENTAL
615
+ - Downnesting
616
+ - Adds spec coverage support for enums
617
+ - Several more fixes; this is preparation for forthcoming release.
618
+ - Some parts still experimental. Use with caution.
619
+
620
+ #### 2021-10-11 - v0.2.6 - many additional automatic fixes for default Rails installation 6 or 7 for the generate hot_glue:install command
621
+
622
+
623
+ #### 2021-10-10 - v0.2.5 - this version is all about developer happyness:
624
+ - significant fixes for the behavioral (system) specs. they now create new & update interactions
625
+ for (almost) all field types
626
+ - 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
627
+ - 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
628
+
629
+ #### 2021-10-07 - v0.2.4 - removes erroneous icons display in delete buttos (these don't work inside of button_to);
630
+ - adds support for ENUM types direclty on your field types
631
+ - you must use activerecord-pgenum
632
+ - see my blog post at https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
633
+
426
634
  #### 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
427
635
 
428
636
  #### 2021-09-27 - v0.2.2 - Fixes some issues with related fields; unlocks Rails 7 in Gemspec file
@@ -457,6 +665,20 @@ If you do not want inline editing of your list items but instead to fall back to
457
665
 
458
666
  #### 2021-02-23 - v0.0.0 - Port of my prior work from github.com/jasonfb/common_core_js
459
667
 
668
+ # PROBLEMS
669
+
670
+ Here are some defeciencies to note
671
+
672
+ - [ ] the ERB output has a necessary gsub that makes it so that every file always kicks the "Overwrite?" even when it has not changed. Unfortunately because of the meta programming involved in the ERB, I do not see a way around this although I would like to eventually fix it or match the AR generator internals to fix this problem.
673
+
674
+ - [ ] the system_spec that is generated (system/*_spec.rb) works most of the time but obviously you must run it to confirm it passes correclty. still working out bugs in this area for special cases.
675
+
676
+
677
+
678
+ - [ ] Note that the specs use FFaker data and random numbers, so if you have model-level validations and out-of-bounds choices are made, your specs might fail *intermittently*.
679
+ ---> I know I hate intermittent failing specs, and if I had any in my app I would surely refactor them out. I'm not sure how I feel about *randomized* data-- or this much randomized data-- in specs. It's kind of fun but it also is tempting fate somewhat, and hopefully encouraging/forcing you to refactor them to be meaningful to your models and model-level validations.
680
+
681
+ - [ ] The specs themselves and some generated code is particularly ugly-- especially, formated inconsistently. Sorry about this, will clean this up soon. It is there to encourage you to read the generated code and lint or rubocop it before you check it in. I know the indentation is off and very ugly.
460
682
 
461
683
 
462
684
  # HOW THIS GEM IS TESTED
data/Rakefile CHANGED
@@ -1,32 +1,42 @@
1
+
1
2
  begin
2
3
  require 'bundler/setup'
3
4
  rescue LoadError
4
5
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
6
  end
6
7
 
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'HotGlue'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.md')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
- APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
18
- load 'rails/tasks/engine.rake'
19
-
20
- load 'rails/tasks/statistics.rake'
21
-
22
- require 'bundler/gem_tasks'
23
-
24
- require 'rake/testtask'
25
-
26
- Rake::TestTask.new(:test) do |t|
27
- t.libs << 'test'
28
- t.pattern = 'test/**/*_test.rb'
29
- t.verbose = false
8
+ begin
9
+ require 'rspec/core/rake_task'
10
+ RSpec::Core::RakeTask.new(:spec)
11
+ task :default => :spec
12
+ rescue LoadError
13
+ puts 'FAILED: unable to load rspec/core/rake_task in Rakefile'
30
14
  end
31
15
 
32
- task default: :test
16
+ #
17
+ # require 'rdoc/task'
18
+ #
19
+ # RDoc::Task.new(:rdoc) do |rdoc|
20
+ # rdoc.rdoc_dir = 'rdoc'
21
+ # rdoc.title = 'HotGlue'
22
+ # rdoc.options << '--line-numbers'
23
+ # rdoc.rdoc_files.include('README.md')
24
+ # rdoc.rdoc_files.include('lib/**/*.rb')
25
+ # end
26
+ #
27
+ # APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
28
+ # load 'rails/tasks/engine.rake'
29
+ #
30
+ # load 'rails/tasks/statistics.rake'
31
+ #
32
+ # require 'bundler/gem_tasks'
33
+
34
+ # require 'rake/testtask'
35
+ #
36
+ # Rake::TestTask.new(:test) do |t|
37
+ # t.libs << 'test'
38
+ # t.pattern = 'test/**/*_test.rb'
39
+ # t.verbose = false
40
+ # end
41
+ #
42
+ # task default: :test
@@ -54,10 +54,12 @@ module HotGlue
54
54
  else
55
55
  server_timezone
56
56
  end
57
- elsif defined?(controller) == "method"
58
- # controller.try(:current_timezone)
59
- elsif self.class.ancestors.include?(ApplicationController)
60
- self.try(:current_timezone)
57
+ elsif true
58
+ server_timezone
59
+ # elsif defined?(controller) == "method"
60
+ # # controller.try(:current_timezone)
61
+ # elsif self.class.ancestors.include?(ApplicationController)
62
+ # self.try(:current_timezone)
61
63
  else
62
64
  raise "no method current_user is available; please implement/override the method current_timezone IN YOUR CONTROLLER"
63
65
  end
@@ -1,4 +1,8 @@
1
1
  module HotGlueHelper
2
2
 
3
+ def enum_to_collection_select(hash)
4
+ hash.collect{|k,v| OpenStruct.new({key: k, value: v})}
5
+
6
+ end
3
7
 
4
8
  end
@@ -0,0 +1,12 @@
1
+ <%= turbo_frame_tag "flash_notices" do %>
2
+ <% unless notice.nil? %>
3
+ <div class="alert alert-notice alert-dismissible">
4
+ <%= notice %>
5
+ </div>
6
+ <% end %>
7
+ <% unless alert.nil? %>
8
+ <div class="alert alert-danger alert-dismissible">
9
+ <%= alert %>
10
+ </div>
11
+ <% end %>
12
+ <% end %>