hot-glue 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +71 -0
- data/.gitignore +2 -1
- data/Gemfile +4 -1
- data/Gemfile.lock +5 -15
- data/README.md +56 -88
- data/config/database.yml +8 -83
- data/db/schema.rb +1 -0
- data/lib/generators/hot_glue/markup_templates/erb.rb +30 -20
- data/lib/generators/hot_glue/scaffold_generator.rb +39 -42
- data/lib/generators/hot_glue/templates/controller.rb.erb +39 -33
- data/lib/generators/hot_glue/templates/erb/_form.erb +3 -2
- data/lib/generators/hot_glue/templates/erb/_new_form.erb +2 -1
- data/lib/generators/hot_glue/templates/erb/new.erb +1 -1
- data/lib/hotglue/version.rb +1 -1
- metadata +4 -17
- data/db/schema.rb +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea7829bc862ee2a0a10b70bc624c31f2f20391731932857423483d27f068a173
|
4
|
+
data.tar.gz: 22f9c32718db75de7d4bd84a5486218b2a75823dba7a2b191bb211cdf5b7770f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d98362fe10be3c546ea9aa253a3141ca936e53adc05028c899667e46601fc8278d818865e503941fcd3d045d300325b083c75cbd507ef70389e904766cc3f46
|
7
|
+
data.tar.gz: 8378310ecb1563d2c7601954d5e0c1bb9494ed49c88ebbe3bc50a15536b19f8dcc5232457e15bdc7ddb27229cf0c87dc4db25fd36861eeeddf0e6ca920c09634
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
2
|
+
# See: https://circleci.com/docs/2.0/configuration-reference
|
3
|
+
version: 2.1
|
4
|
+
|
5
|
+
# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
|
6
|
+
# See: https://circleci.com/docs/2.0/orb-intro/
|
7
|
+
orbs:
|
8
|
+
ruby: circleci/ruby@1.4.0
|
9
|
+
|
10
|
+
# Define a job to be invoked later in a workflow.
|
11
|
+
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
|
12
|
+
jobs:
|
13
|
+
build:
|
14
|
+
docker:
|
15
|
+
- image: cimg/ruby:2.7.5-browsers
|
16
|
+
executor: ruby/default
|
17
|
+
steps:
|
18
|
+
- checkout
|
19
|
+
- ruby/install-deps # use the ruby orb to install dependencies
|
20
|
+
|
21
|
+
- run:
|
22
|
+
name: Which bundler?
|
23
|
+
command: bundle -v
|
24
|
+
test: # our next job, called "test"
|
25
|
+
parallelism: 1
|
26
|
+
# here we set TWO docker images.
|
27
|
+
docker:
|
28
|
+
|
29
|
+
- image: cimg/ruby:2.7.5-browsers # this is our primary docker image, where step commands run.
|
30
|
+
auth:
|
31
|
+
username: mydockerhub-user
|
32
|
+
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference
|
33
|
+
- image: redis:6.2.6
|
34
|
+
- image: circleci/postgres:9.5-alpine
|
35
|
+
auth:
|
36
|
+
username: mydockerhub-user
|
37
|
+
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference
|
38
|
+
environment: # add POSTGRES environment variables.
|
39
|
+
POSTGRES_USER: circleci-demo-ruby
|
40
|
+
POSTGRES_DB: hot-glue-test
|
41
|
+
POSTGRES_PASSWORD: ""
|
42
|
+
# environment variables specific to Ruby/Rails, applied to the primary container.
|
43
|
+
environment:
|
44
|
+
BUNDLE_JOBS: "3"
|
45
|
+
BUNDLE_RETRY: "3"
|
46
|
+
PGHOST: 127.0.0.1
|
47
|
+
PGUSER: circleci-demo-ruby
|
48
|
+
PGPASSWORD: ""
|
49
|
+
RAILS_ENV: test
|
50
|
+
# A series of steps to run, some are similar to those in "build".
|
51
|
+
steps:
|
52
|
+
- checkout
|
53
|
+
- ruby/install-deps
|
54
|
+
# Here we make sure that the secondary container boots
|
55
|
+
# up before we run operations on the database.
|
56
|
+
- run:
|
57
|
+
name: Wait for DB
|
58
|
+
command: dockerize -wait tcp://localhost:5432 -timeout 1m
|
59
|
+
# Run rspec in parallel
|
60
|
+
- ruby/rspec-test
|
61
|
+
|
62
|
+
# We use workflows to orchestrate the jobs that we declared above.
|
63
|
+
workflows:
|
64
|
+
version: 2
|
65
|
+
build_and_test: # The name of our workflow is "build_and_test"
|
66
|
+
jobs: # The list of jobs we run as part of this workflow.
|
67
|
+
- build # Run build first.
|
68
|
+
- test: # Then run test,
|
69
|
+
requires: # Test requires that build passes for it to run.
|
70
|
+
- build # Finally, run the build job.
|
71
|
+
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# THESE GEMS ARE NOT PART OF YOUR RAILS APP!!!
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
5
|
|
4
6
|
gemspec
|
5
7
|
|
6
8
|
# not required for your app
|
7
|
-
gem '
|
9
|
+
gem 'sqlite3'
|
8
10
|
gem 'byebug'
|
9
11
|
gem 'rails'
|
10
12
|
gem 'devise', require: true
|
@@ -13,4 +15,5 @@ gem 'devise', require: true
|
|
13
15
|
gem "rails-controller-testing", group: [:test]
|
14
16
|
gem "database_cleaner", group: [:test]
|
15
17
|
gem "rspec-rails", group: [:test]
|
18
|
+
gem "rspec_junit_formatter", group: [:test]
|
16
19
|
gem "factory_bot", group: [:test]
|
data/Gemfile.lock
CHANGED
@@ -5,7 +5,6 @@ PATH
|
|
5
5
|
ffaker (~> 2.16)
|
6
6
|
kaminari (~> 1.2)
|
7
7
|
rails (> 5.1)
|
8
|
-
sass-rails
|
9
8
|
|
10
9
|
GEM
|
11
10
|
remote: https://rubygems.org/
|
@@ -91,7 +90,6 @@ GEM
|
|
91
90
|
factory_bot (6.2.0)
|
92
91
|
activesupport (>= 5.0.0)
|
93
92
|
ffaker (2.20.0)
|
94
|
-
ffi (1.15.5)
|
95
93
|
globalid (0.4.2)
|
96
94
|
activesupport (>= 4.2.0)
|
97
95
|
i18n (1.8.10)
|
@@ -127,7 +125,6 @@ GEM
|
|
127
125
|
mini_portile2 (~> 2.5.0)
|
128
126
|
racc (~> 1.4)
|
129
127
|
orm_adapter (0.5.0)
|
130
|
-
pg (1.2.3)
|
131
128
|
racc (1.5.2)
|
132
129
|
rack (2.2.3)
|
133
130
|
rack-test (1.1.0)
|
@@ -183,16 +180,8 @@ GEM
|
|
183
180
|
rspec-mocks (~> 3.10)
|
184
181
|
rspec-support (~> 3.10)
|
185
182
|
rspec-support (3.10.2)
|
186
|
-
|
187
|
-
|
188
|
-
sassc (2.4.0)
|
189
|
-
ffi (~> 1.9)
|
190
|
-
sassc-rails (2.1.2)
|
191
|
-
railties (>= 4.0.0)
|
192
|
-
sassc (>= 2.0)
|
193
|
-
sprockets (> 3.0)
|
194
|
-
sprockets-rails
|
195
|
-
tilt
|
183
|
+
rspec_junit_formatter (0.5.1)
|
184
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
196
185
|
sprockets (4.0.2)
|
197
186
|
concurrent-ruby (~> 1.0)
|
198
187
|
rack (> 1, < 3)
|
@@ -200,8 +189,8 @@ GEM
|
|
200
189
|
actionpack (>= 4.0)
|
201
190
|
activesupport (>= 4.0)
|
202
191
|
sprockets (>= 3.0.0)
|
192
|
+
sqlite3 (1.4.2)
|
203
193
|
thor (1.1.0)
|
204
|
-
tilt (2.0.10)
|
205
194
|
tzinfo (2.0.4)
|
206
195
|
concurrent-ruby (~> 1.0)
|
207
196
|
warden (1.2.9)
|
@@ -221,10 +210,11 @@ DEPENDENCIES
|
|
221
210
|
devise
|
222
211
|
factory_bot
|
223
212
|
hot-glue!
|
224
|
-
pg
|
225
213
|
rails
|
226
214
|
rails-controller-testing
|
227
215
|
rspec-rails
|
216
|
+
rspec_junit_formatter
|
217
|
+
sqlite3
|
228
218
|
|
229
219
|
BUNDLED WITH
|
230
220
|
2.1.4
|
data/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
|
2
|
-
[![
|
3
|
-
|
2
|
+
[![Hot Glue](https://circleci.com/gh/jasonfb/hot-glue.svg?style=shield)](https://circleci.com/gh/jasonfb/hot-glue)
|
4
3
|
|
5
4
|
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
5
|
|
@@ -79,11 +78,17 @@ _BOOTSTRAP IS NO LONGER NEEDED_, but I recommend it.
|
|
79
78
|
|
80
79
|
IF you are using `--layout=bootstrap` (step 3), you must install Bootstrap here.
|
81
80
|
|
82
|
-
|
81
|
+
Webpacker is no longer in Rails 7. Also, there is a new option for Rails 7 to build Bootstrap using `cssbundling-rails`
|
82
|
+
|
83
|
+
|
84
|
+
|
83
85
|
|
84
|
-
For Bootstrap with Sprockets (recommended by Rails team), see https://github.com/twbs/bootstrap-rubygem
|
85
86
|
|
86
|
-
|
87
|
+
For the old method:
|
88
|
+
|
89
|
+
- https://github.com/twbs/bootstrap-rubygem
|
90
|
+
|
91
|
+
With the old method, install the gem using:
|
87
92
|
```
|
88
93
|
gem 'bootstrap', '~> 5.1.3'
|
89
94
|
```
|
@@ -243,7 +248,7 @@ https://github.com/FortAwesome/font-awesome-sass
|
|
243
248
|
|
244
249
|
Add to your Gemfile
|
245
250
|
|
246
|
-
As of
|
251
|
+
As of 2022-01-26 Devise for Rails 7 is still not released so you must use main branch, like so:
|
247
252
|
`gem 'devise', branch: 'main', git: 'https://github.com/heartcombo/devise.git'`
|
248
253
|
|
249
254
|
If on Rails 6 **or** Rails 7, you must do the steps in **Legacy Step #5** (below).
|
@@ -252,6 +257,7 @@ If on Rails 6 **or** Rails 7, you must do the steps in **Legacy Step #5** (below
|
|
252
257
|
|
253
258
|
To be clear: You CAN use Devise with Rails 7, but you must still do the Legacy Step #5 described below for your login to work.
|
254
259
|
|
260
|
+
You MUST run the installer FIRST or else you will put your app into a non-workable state:
|
255
261
|
```
|
256
262
|
rails generate devise:install
|
257
263
|
```
|
@@ -277,6 +283,18 @@ As described in Legacy Step #5, **you cannot** skip Devise installer Step 4, eve
|
|
277
283
|
Once you copy the files, you must modify the Devise views to disable Turbo as described in Legacy Step #5.
|
278
284
|
|
279
285
|
|
286
|
+
Be sure to create primary auth model with:
|
287
|
+
|
288
|
+
`rails generate devise User name:string`
|
289
|
+
|
290
|
+
Remember, you don't need to tell Devise that your User has an email, an encrypted password, a reset token, and a 'remember me' flag to let the user stay logged in.
|
291
|
+
|
292
|
+
Those features come by default with Devise, and you'll find the fields for them in the newly generated migration file.
|
293
|
+
|
294
|
+
In the example above, you are creating all of those fields along with a simple 'name' (string) field for your User table.
|
295
|
+
|
296
|
+
|
297
|
+
|
280
298
|
## LEGACY SETUP FOR RAILS 6
|
281
299
|
|
282
300
|
(Note Legacy Step #5 is necessary for BOTH Rails 6 and Rails 7.)
|
@@ -404,17 +422,27 @@ end
|
|
404
422
|
```
|
405
423
|
|
406
424
|
|
407
|
-
### `--
|
425
|
+
### `--nested=`
|
426
|
+
|
427
|
+
This object is nested within another tree of objects, and there is a nested route in your routes.rb file
|
428
|
+
|
429
|
+
resources :invoices do
|
430
|
+
resource :lines do
|
431
|
+
end
|
432
|
+
|
408
433
|
|
409
|
-
|
434
|
+
`rails generate hot_glue:scaffold Line --nested=invoice`
|
410
435
|
|
411
436
|
|
412
|
-
|
437
|
+
Example #1: Invoice has many :lines and line belongs_to :invoice
|
413
438
|
|
414
|
-
In this example, it is presumed that the current user has_many :invoices, and that invoices have many :lines
|
415
439
|
|
440
|
+
For multi-level nesting use slashes to separate your levels of nesting.
|
441
|
+
|
442
|
+
`rails generate hot_glue:scaffold Charge --nested=invoice`
|
443
|
+
`rails generate hot_glue:scaffold Charge --nest=invoice/line`
|
416
444
|
|
417
|
-
|
445
|
+
Remember, you should match what you have in your routes.rb file.
|
418
446
|
|
419
447
|
```
|
420
448
|
resources :invoices do
|
@@ -424,13 +452,10 @@ resources :invoices do
|
|
424
452
|
end
|
425
453
|
|
426
454
|
```
|
427
|
-
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
|
428
455
|
|
456
|
+
For non-Gd controllers, your auth root will be used as the starting point when loading the objects from the URL if this object is nested.
|
429
457
|
|
430
|
-
|
431
|
-
`rails generate hot_glue:scaffold Charge --nest=invoice/line`
|
432
|
-
|
433
|
-
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:
|
458
|
+
(For Gd controllers the root object will be loaded directly from the ActiveRecord object.)
|
434
459
|
|
435
460
|
In the example above, @invoice will be loaded from
|
436
461
|
|
@@ -444,11 +469,14 @@ Then, finally the @charge will be loaded
|
|
444
469
|
|
445
470
|
`@charge = @line.charges.find(params[:id])`
|
446
471
|
|
447
|
-
|
472
|
+
This is "starfish access control" or "poor man's access control." It works when the current user has several things they can manage, and by extension can manage children of those things.
|
473
|
+
|
474
|
+
|
475
|
+
## Optional Nesting
|
448
476
|
|
449
|
-
|
477
|
+
**God controllers only ** have a special build feature where they can be specified to be optionally nested.
|
450
478
|
|
451
|
-
|
479
|
+
When build as optionally nested,
|
452
480
|
|
453
481
|
|
454
482
|
### `--auth=`
|
@@ -623,69 +651,6 @@ You will need to build scaffolding with the same name for the related object as
|
|
623
651
|
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.
|
624
652
|
|
625
653
|
|
626
|
-
### `--alt-controller-name`
|
627
|
-
|
628
|
-
Normally a controller a has a natural name based on the model (the Thing model produces a `ThingsController`).
|
629
|
-
|
630
|
-
Within any given namespace, you can have only one natural controller for that model, of course, because all the controllers exist at the namespace directory even when they are nested.
|
631
|
-
|
632
|
-
For example, let's say you have an Admin dashboard with User has_many :invoices
|
633
|
-
|
634
|
-
Your routes file will nest your invoices within your users (for whatever namespace you are building)
|
635
|
-
|
636
|
-
```
|
637
|
-
namespace :admin do
|
638
|
-
resources :users do
|
639
|
-
resources :invoices
|
640
|
-
end
|
641
|
-
end
|
642
|
-
```
|
643
|
-
|
644
|
-
Therefore, your namespace can typically only view that model in one context. If that context is nested (using `--nest` exists at a nested route), it can only be used in the context of that nest (which probably requires one or more parent objects to be in the nested route of your URL).
|
645
|
-
|
646
|
-
You should preserve this naming convention, and stay within those guides so your nested routes work when this object is nested within another object's view. (For the context of that or any namespace.)
|
647
|
-
|
648
|
-
Alternative controller names let you specify a controller name that is nameed _something else_ but still edits the given object/table.
|
649
|
-
|
650
|
-
In the example above, you'd add another top-level route in the same namespace called "all_X".
|
651
|
-
|
652
|
-
For example,
|
653
|
-
|
654
|
-
**config/routes.rb**
|
655
|
-
```
|
656
|
-
namespace :admin do
|
657
|
-
resources :users do
|
658
|
-
resources :invoices
|
659
|
-
end
|
660
|
-
resources :all_invoices
|
661
|
-
end
|
662
|
-
```
|
663
|
-
|
664
|
-
Then you'd build normal nested scaffold like so:
|
665
|
-
|
666
|
-
```
|
667
|
-
rails generate hot_glue:scaffold User --namespace=admin --gd
|
668
|
-
|
669
|
-
rails generate hot_glue:scaffold Invoice --namespace=admin --nest=users --gd
|
670
|
-
|
671
|
-
```
|
672
|
-
You'd build another Invoices controller like this:
|
673
|
-
|
674
|
-
```
|
675
|
-
rails generate hot_glue:scaffold Invoice --namespace=admin --alt-controller-name=AllInvoices --gd
|
676
|
-
```
|
677
|
-
|
678
|
-
Note that all three builds here are in the `admin` namespace (so build controllers at `app/controllers/admin/`) and ALSO use Gd mode.
|
679
|
-
|
680
|
-
If you extend the example conceptually you build things like "UnpaidInvoices" or "RecentInvoices" which would, for example, build contextual views for the admin user.
|
681
|
-
|
682
|
-
The difference between the one kind of Invoices controller and the other is that, in this example, the InvoicesController (the natural one) is always nested to the user. So if you ever want to know about invoices in the context of a user, that's exactly what you use.
|
683
|
-
|
684
|
-
The other one, `AllInvoicesController` or `UnpaidInvoicesController` will provide the admin a view of invoices **out of the context** of the user object.
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
654
|
|
690
655
|
|
691
656
|
## FLAGS (Options with no values)
|
@@ -779,6 +744,8 @@ Obviously, the created controller will always have this base controller as its s
|
|
779
744
|
|
780
745
|
# VERSION HISTORY
|
781
746
|
|
747
|
+
#### 2022-01-25 - v0.4.7 -
|
748
|
+
|
782
749
|
#### 2022-01-11 - v0.4.5 - buttons on smarty layouts take up 1 bootstrap column each; fixes confirmation alert for delete buttons
|
783
750
|
|
784
751
|
#### 2022-01-01 - v0.4.3 and 0.4.4 - adding fully email based license; no activation codes required
|
@@ -856,9 +823,9 @@ SETUP:
|
|
856
823
|
• 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
|
857
824
|
|
858
825
|
|
859
|
-
The dummy sandbox is found at `spec/
|
826
|
+
The dummy sandbox is found at `spec/Dummy`
|
860
827
|
|
861
|
-
The dummy sandbox lives as mostly checked- into the repository, **except** the folders where the generated code goes (`spec/
|
828
|
+
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)
|
862
829
|
|
863
830
|
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.
|
864
831
|
|
@@ -867,15 +834,16 @@ The DUMMY testing DOES NOT test the actual functionality of the output code (it
|
|
867
834
|
|
868
835
|
# DATABASE
|
869
836
|
|
870
|
-
`cd spec/
|
837
|
+
`cd spec/Dummy`
|
871
838
|
`rails db:drop`
|
872
839
|
`rails db:create`
|
873
840
|
`rails db:migrate`
|
874
841
|
`RAILS_ENV=test rails db:migrate`
|
875
842
|
|
876
|
-
`cd ../..`
|
877
843
|
|
878
|
-
|
879
|
-
|
844
|
+
being able to run `rake spec` at the root of this repo is acheived using
|
845
|
+
```
|
846
|
+
ln -s spec/dummy/db/schema.rb db/schema.rb
|
847
|
+
```
|
880
848
|
|
881
849
|
|
data/config/database.yml
CHANGED
@@ -1,86 +1,11 @@
|
|
1
|
-
# PostgreSQL. Versions 9.3 and up are supported.
|
2
|
-
#
|
3
|
-
# Install the pg driver:
|
4
|
-
# gem install pg
|
5
|
-
# On macOS with Homebrew:
|
6
|
-
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
|
7
|
-
# On macOS with MacPorts:
|
8
|
-
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
|
9
|
-
# On Windows:
|
10
|
-
# gem install pg
|
11
|
-
# Choose the win32 build.
|
12
|
-
# Install PostgreSQL and put its /bin directory on your path.
|
13
|
-
#
|
14
|
-
# Configure Using Gemfile
|
15
|
-
# gem 'pg'
|
16
|
-
#
|
17
|
-
default: &default
|
18
|
-
adapter: postgresql
|
19
|
-
encoding: unicode
|
20
|
-
# For details on connection pooling, see Rails configuration guide
|
21
|
-
# https://guides.rubyonrails.org/configuring.html#database-pooling
|
22
|
-
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
23
|
-
|
24
1
|
development:
|
25
|
-
|
26
|
-
database:
|
27
|
-
|
28
|
-
|
29
|
-
# To create additional roles in postgres see `$ createuser --help`.
|
30
|
-
# When left blank, postgres will use the default role. This is
|
31
|
-
# the same name as the operating system user running Rails.
|
32
|
-
#username: Dummy
|
33
|
-
|
34
|
-
# The password associated with the postgres role (username).
|
35
|
-
#password:
|
36
|
-
|
37
|
-
# Connect on a TCP socket. Omitted by default since the client uses a
|
38
|
-
# domain socket that doesn't need configuration. Windows does not have
|
39
|
-
# domain sockets, so uncomment these lines.
|
40
|
-
#host: localhost
|
2
|
+
adapter: sqlite3
|
3
|
+
database: ../spec/dummy/db/development.sqlite3
|
4
|
+
pool: 5
|
5
|
+
timeout: 5000
|
41
6
|
|
42
|
-
# The TCP port the server listens on. Defaults to 5432.
|
43
|
-
# If your server runs on a different port number, change accordingly.
|
44
|
-
#port: 5432
|
45
|
-
|
46
|
-
# Schema search path. The server defaults to $user,public
|
47
|
-
#schema_search_path: myapp,sharedapp,public
|
48
|
-
|
49
|
-
# Minimum log levels, in increasing order:
|
50
|
-
# debug5, debug4, debug3, debug2, debug1,
|
51
|
-
# log, notice, warning, error, fatal, and panic
|
52
|
-
# Defaults to warning.
|
53
|
-
#min_messages: notice
|
54
|
-
|
55
|
-
# Warning: The database defined as "test" will be erased and
|
56
|
-
# re-generated from your development database when you run "rake".
|
57
|
-
# Do not set this db to the same as development or production.
|
58
7
|
test:
|
59
|
-
|
60
|
-
database:
|
61
|
-
|
62
|
-
|
63
|
-
# like your database password, in your source code. If your source code is
|
64
|
-
# ever seen by anyone, they now have access to your database.
|
65
|
-
#
|
66
|
-
# Instead, provide the password or a full connection URL as an environment
|
67
|
-
# variable when you boot the app. For example:
|
68
|
-
#
|
69
|
-
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
|
70
|
-
#
|
71
|
-
# If the connection URL is provided in the special DATABASE_URL environment
|
72
|
-
# variable, Rails will automatically merge its configuration values on top of
|
73
|
-
# the values provided in this file. Alternatively, you can specify a connection
|
74
|
-
# URL environment variable explicitly:
|
75
|
-
#
|
76
|
-
# production:
|
77
|
-
# url: <%= ENV['MY_APP_DATABASE_URL'] %>
|
78
|
-
#
|
79
|
-
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
|
80
|
-
# for a full overview on how database connection configuration can be specified.
|
81
|
-
#
|
82
|
-
production:
|
83
|
-
<<: *default
|
84
|
-
database: Dummy_production
|
85
|
-
username: Dummy
|
86
|
-
password: <%= ENV['DUMMY_DATABASE_PASSWORD'] %>
|
8
|
+
adapter: sqlite3
|
9
|
+
database: ../spec/dummy/db/test.sqlite3
|
10
|
+
pool: 5
|
11
|
+
timeout: 5000
|
data/db/schema.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
db/spec/dummy/db/schema.rb
|
@@ -1,12 +1,20 @@
|
|
1
1
|
module HotGlue
|
2
2
|
class ErbTemplate < TemplateBase
|
3
3
|
|
4
|
+
|
5
|
+
|
6
|
+
def add_spaces_each_line(text, num_spaces)
|
7
|
+
add_spaces = " " * num_spaces
|
8
|
+
text.lines.collect{|line| add_spaces + line}.join("")
|
9
|
+
end
|
10
|
+
|
11
|
+
|
4
12
|
# include GeneratorHelper
|
5
13
|
attr_accessor :singular
|
6
14
|
|
7
15
|
def field_output(col, type = nil, width, col_identifier )
|
8
16
|
" <%= f.text_field :#{col.to_s}, value: @#{@singular}.#{col.to_s}, autocomplete: 'off', size: #{width}, class: 'form-control', type: '#{type}' %>\n "+
|
9
|
-
"
|
17
|
+
"\n"
|
10
18
|
end
|
11
19
|
|
12
20
|
|
@@ -31,8 +39,7 @@ module HotGlue
|
|
31
39
|
lines = 5
|
32
40
|
end
|
33
41
|
|
34
|
-
"<%= f.text_area :#{col.to_s}, class: 'form-control', autocomplete: 'off', cols: 40, rows: '#{lines}' %>"
|
35
|
-
"<label class='form-text'>#{col.to_s.humanize}</label>"
|
42
|
+
"<%= f.text_area :#{col.to_s}, class: 'form-control', autocomplete: 'off', cols: 40, rows: '#{lines}' %>"
|
36
43
|
end
|
37
44
|
|
38
45
|
def list_column_headings(*args)
|
@@ -59,23 +66,20 @@ module HotGlue
|
|
59
66
|
show_only = args[0][:show_only]
|
60
67
|
singular_class = args[0][:singular_class]
|
61
68
|
col_identifier = args[0][:col_identifier]
|
69
|
+
ownership_field = args[0][:ownership_field]
|
62
70
|
|
63
71
|
|
64
72
|
# TODO: CLEAN ME
|
65
73
|
@singular = args[0][:singular]
|
66
74
|
singular = @singular
|
67
75
|
|
68
|
-
col_spaces_prepend = " "
|
69
|
-
|
70
|
-
|
71
76
|
result = layout_columns.map{ |column|
|
72
|
-
"<div class='#{col_identifier}' >" +
|
77
|
+
" <div class='#{col_identifier}' >" +
|
73
78
|
|
74
79
|
column.map { |col|
|
75
80
|
|
76
81
|
field_result = if show_only.include?(col)
|
77
|
-
"<%= @#{singular}.#{col.to_s} %>"
|
78
|
-
"<label class='form-text'>#{col.to_s.humanize}</label>"
|
82
|
+
"<%= @#{singular}.#{col.to_s} %>"
|
79
83
|
else
|
80
84
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
81
85
|
limit = eval("#{singular_class}.columns_hash['#{col}']").limit
|
@@ -88,16 +92,18 @@ module HotGlue
|
|
88
92
|
assoc_name = col.to_s.gsub("_id","")
|
89
93
|
assoc = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
|
90
94
|
if assoc.nil?
|
91
|
-
exit_message= "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
|
95
|
+
exit_message = "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
|
92
96
|
exit
|
93
97
|
end
|
98
|
+
|
99
|
+
is_owner = col.to_s == ownership_field
|
94
100
|
display_column = HotGlue.derrive_reference_name(assoc.class_name)
|
95
|
-
|
96
|
-
|
101
|
+
|
102
|
+
# TODO: add is_owner && check if this nested arg is optional
|
103
|
+
(is_owner ? "<% unless #{assoc_name} %>\n" : "") + " <%= f.collection_select(:#{col.to_s}, #{assoc.class_name}.all, :id, :#{display_column}, {prompt: true, selected: @#{singular}.#{col.to_s} }, class: 'form-control') %>\n" + (is_owner ? "<% end %>" : "")
|
97
104
|
|
98
105
|
else
|
99
|
-
"<%= f.text_field :#{col.to_s}, value: #{singular}.#{col.to_s}, class: 'form-control', size: 4, type: 'number' %>
|
100
|
-
<label class='small form-text text-muted'>#{col.to_s.humanize}</label>"
|
106
|
+
"<%= f.text_field :#{col.to_s}, value: #{singular}.#{col.to_s}, class: 'form-control', size: 4, type: 'number' %>"
|
101
107
|
|
102
108
|
end
|
103
109
|
when :string
|
@@ -131,18 +137,22 @@ module HotGlue
|
|
131
137
|
""
|
132
138
|
when :enum
|
133
139
|
enum_type = eval("#{singular_class}.columns.select{|x| x.name == '#{col.to_s}'}[0].sql_type")
|
134
|
-
"<%= f.collection_select(:#{col.to_s}, enum_to_collection_select( #{singular_class}.defined_enums['#{enum_type}']), :key, :value, {selected: @#{singular}.#{col.to_s} }, class: 'form-control') %>
|
135
|
-
|
136
|
-
|
137
|
-
|
140
|
+
"<%= f.collection_select(:#{col.to_s}, enum_to_collection_select( #{singular_class}.defined_enums['#{enum_type}']), :key, :value, {selected: @#{singular}.#{col.to_s} }, class: 'form-control') %>"
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
138
144
|
|
139
145
|
if (type == :integer) && col.to_s.ends_with?("_id")
|
140
146
|
field_error_name = col.to_s.gsub("_id","")
|
141
147
|
else
|
142
148
|
field_error_name = col.to_s
|
143
149
|
end
|
144
|
-
|
145
|
-
|
150
|
+
|
151
|
+
add_spaces_each_line( "\n <span class='<%= \"alert-danger\" if #{singular}.errors.details.keys.include?(:#{field_error_name}) %>' #{ 'style="display: inherit;"'} >\n" +
|
152
|
+
add_spaces_each_line(field_result + "\n<label class='small form-text text-muted'>#{col.to_s.humanize}</label>", 4) +
|
153
|
+
"\n </span>\n <br />", 2)
|
154
|
+
|
155
|
+
}.join("") + "\n </div>"
|
146
156
|
}.join("\n")
|
147
157
|
return result
|
148
158
|
end
|
@@ -41,7 +41,10 @@ module HotGlue
|
|
41
41
|
class_option :singular, type: :string, default: nil
|
42
42
|
class_option :plural, type: :string, default: nil
|
43
43
|
class_option :singular_class, type: :string, default: nil
|
44
|
-
class_option :nest, type: :string, default:
|
44
|
+
class_option :nest, type: :string, default: nil # DEPRECATED —— DO NOT USE
|
45
|
+
class_option :nested, type: :string, default: ""
|
46
|
+
|
47
|
+
|
45
48
|
class_option :namespace, type: :string, default: nil
|
46
49
|
class_option :auth, type: :string, default: nil
|
47
50
|
class_option :auth_identifier, type: :string, default: nil
|
@@ -70,7 +73,7 @@ module HotGlue
|
|
70
73
|
class_option :markup, type: :string, default: nil # deprecated -- use in app config instead
|
71
74
|
class_option :layout, type: :string, default: nil # if used here it will override what is in the config
|
72
75
|
class_option :no_list_labels, type: :boolean, default: false
|
73
|
-
class_option :
|
76
|
+
class_option :before_list_labels, type: :boolean, default: false
|
74
77
|
|
75
78
|
def initialize(*meta_args)
|
76
79
|
super
|
@@ -148,27 +151,27 @@ module HotGlue
|
|
148
151
|
@namespace = options['namespace'] || nil
|
149
152
|
|
150
153
|
|
151
|
-
|
152
|
-
use_controller_name = @alt_controller_name || plural.titleize.gsub(" ", "")
|
154
|
+
use_controller_name = plural.titleize.gsub(" ", "")
|
153
155
|
|
154
|
-
@controller_build_name = (( @namespace.titleize + "::" if @namespace) || "") + use_controller_name + "Controller"
|
156
|
+
@controller_build_name = (( @namespace.titleize.gsub(" ","") + "::" if @namespace) || "") + use_controller_name + "Controller"
|
155
157
|
@controller_build_folder = use_controller_name.underscore
|
158
|
+
@controller_build_folder_singular = singular
|
156
159
|
|
157
160
|
if ! @controller_build_folder.ends_with?("s")
|
158
161
|
raise "can't build with controller name #{@controller_build_folder} because it doesn't end with an 's'"
|
159
162
|
end
|
160
163
|
|
161
|
-
if @alt_controller_name
|
162
|
-
@controller_build_folder_singular = @controller_build_folder.gsub(/s$/,'')
|
163
|
-
else
|
164
|
-
@controller_build_folder_singular = singular
|
165
|
-
end
|
166
|
-
|
167
164
|
@auth = options['auth'] || "current_user"
|
168
165
|
@auth_identifier = options['auth_identifier'] || (! @god && @auth.gsub("current_", "")) || nil
|
169
166
|
|
170
167
|
|
171
|
-
|
168
|
+
|
169
|
+
if options['nest']
|
170
|
+
raise "STOP: the flag --nest has been replaced with --nested; please re-run using the --nested flag"
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
@nested = (!options['nested'].empty? && options['nested']) || nil
|
172
175
|
|
173
176
|
@singular_class = @singular.titleize.gsub(" ", "")
|
174
177
|
@exclude_fields = []
|
@@ -204,7 +207,6 @@ module HotGlue
|
|
204
207
|
@smart_layout = options['smart_layout']
|
205
208
|
|
206
209
|
|
207
|
-
|
208
210
|
@container_name = @layout == "hotglue" ? "scaffold-container" : "container-fluid"
|
209
211
|
@downnest = options['downnest'] || false
|
210
212
|
|
@@ -220,13 +222,18 @@ module HotGlue
|
|
220
222
|
end
|
221
223
|
|
222
224
|
# when in self auth, the object is the same as the authenticated object
|
225
|
+
|
223
226
|
if @auth && auth_identifier == @singular
|
224
227
|
@self_auth = true
|
225
228
|
end
|
226
229
|
|
230
|
+
if @self_auth && !@no_create
|
231
|
+
raise "This controller appears to be the same as the authentication object but in this context you cannot build a new/create action; please re-run with --no-create flag"
|
232
|
+
end
|
233
|
+
|
227
234
|
@nested_args = []
|
228
|
-
if
|
229
|
-
@nested_args = @
|
235
|
+
if ! @nested.nil?
|
236
|
+
@nested_args = @nested.split("/")
|
230
237
|
@nested_args_plural = {}
|
231
238
|
@nested_args.each do |a|
|
232
239
|
@nested_args_plural[a] = a + "s"
|
@@ -266,13 +273,16 @@ module HotGlue
|
|
266
273
|
|
267
274
|
if !@ujs_syntax
|
268
275
|
@ujs_syntax = !defined?(Turbo::Engine)
|
269
|
-
puts "You did not specify ujs_syntax and so I default it to #{@ujs_syntax}"
|
270
276
|
end
|
271
277
|
@reference_name = HotGlue.derrive_reference_name(singular_class)
|
272
278
|
|
273
279
|
identify_object_owner
|
274
280
|
setup_fields
|
275
281
|
|
282
|
+
if (@columns - @show_only - (@object_owner_sym.empty? ? [] : [@ownership_field.to_sym])).empty?
|
283
|
+
@no_field_form = true
|
284
|
+
end
|
285
|
+
|
276
286
|
buttons_width = ((!@no_edit && 1) || 0) + ((!@no_delete && 1) || 0) + @magic_buttons.count
|
277
287
|
|
278
288
|
builder = HotGlue::Layout::Builder.new({
|
@@ -297,30 +307,16 @@ module HotGlue
|
|
297
307
|
|
298
308
|
if assoc
|
299
309
|
@ownership_field = assoc.name.to_s + "_id"
|
300
|
-
elsif
|
310
|
+
elsif ! @nested_args.any?
|
301
311
|
exit_message = "*** Oops: It looks like is no association from current_#{@object_owner_sym} to a class called #{@singular_class}. If your user is called something else, pass with flag auth=current_X where X is the model for your users as lowercase. Also, be sure to implement current_X as a method on your controller. (If you really don't want to implement a current_X on your controller and want me to check some other method for your current user, see the section in the docs for auth_identifier.) To make a controller that can read all records, specify with --god."
|
302
312
|
|
303
313
|
else
|
304
|
-
exit_message = "*** Oops: Missing relationship from class #{singular_class} to :#{@object_owner_sym} \n
|
305
|
-
maybe add `belongs_to :#{@object_owner_sym}` to #{singular_class}\n
|
306
|
-
(If your user is called something else, pass with flag auth=current_X where X is the model for your auth object as lowercase.
|
307
|
-
Also, be sure to implement current_X as a method on your controller. If you really don't want to implement a current_X on your controller and want me to check some other method for your current user, see the section in the docs for --auth-identifier flag)
|
308
314
|
|
309
|
-
|
310
|
-
|
311
|
-
if @god
|
312
|
-
exit_message << "does #{singular_class} have a relOops: Gd mode could not find the association(#{@object_owner_sym}). Something is wrong."
|
315
|
+
if eval(singular_class + ".reflect_on_association(:#{@object_owner_sym.to_s})").nil? && !eval(singular_class + ".reflect_on_association(:#{@object_owner_sym.to_s.singularize})").nil?
|
316
|
+
exit_message = "*** Oops: you tried to nest #{singular_class} within a route for `#{@object_owner_sym}` but I can't find an association for this relationship. Did you mean `#{@object_owner_sym.to_s.singularize}` (singular) instead?"
|
313
317
|
else
|
314
|
-
|
315
|
-
@auth_check = eval(@auth_identifier.titleize)
|
316
|
-
@nested_args.each do |arg|
|
317
|
-
|
318
|
-
if ! @auth_check.reflect_on_association("#{arg}s".to_sym)
|
319
|
-
exit_message << "... your nesting chain does not have a association for #{arg}s on #{@auth_check} something is wrong."
|
320
|
-
end
|
321
|
-
end
|
318
|
+
exit_message = "*** Oops: Missing relationship from class #{singular_class} to :#{@object_owner_sym} maybe add `belongs_to :#{@object_owner_sym}` to #{singular_class}\n (If your user is called something else, pass with flag auth=current_X where X is the model for your auth object as lowercase. Also, be sure to implement current_X as a method on your controller. If you really don't want to implement a current_X on your controller and want me to check some other method for your current user, see the section in the docs for --auth-identifier flag). To make a controller that can read all records, specify with --god."
|
322
319
|
end
|
323
|
-
puts "\n" + exit_message
|
324
320
|
raise(HotGlue::Error, exit_message)
|
325
321
|
end
|
326
322
|
end
|
@@ -520,7 +516,7 @@ To make a controller that can read all records, specify with --god."
|
|
520
516
|
end
|
521
517
|
|
522
518
|
def path_helper_args
|
523
|
-
if @nested_args.any? && @
|
519
|
+
if @nested_args.any? && @nested
|
524
520
|
[(@nested_args).collect{|a| "#{a}"} , singular].join(",")
|
525
521
|
else
|
526
522
|
singular
|
@@ -528,7 +524,7 @@ To make a controller that can read all records, specify with --god."
|
|
528
524
|
end
|
529
525
|
|
530
526
|
def path_helper_singular
|
531
|
-
if @
|
527
|
+
if @nested
|
532
528
|
"#{@namespace+"_" if @namespace}#{(@nested_args.join("_") + "_" if @nested_args.any?)}#{@controller_build_folder_singular}_path"
|
533
529
|
else
|
534
530
|
"#{@namespace+"_" if @namespace}#{@controller_build_folder_singular}_path"
|
@@ -536,7 +532,7 @@ To make a controller that can read all records, specify with --god."
|
|
536
532
|
end
|
537
533
|
|
538
534
|
def path_helper_plural
|
539
|
-
if ! @
|
535
|
+
if ! @nested
|
540
536
|
"#{@namespace+"_" if @namespace}#{@controller_build_folder}_path"
|
541
537
|
else
|
542
538
|
"#{@namespace+"_" if @namespace}#{(@nested_args.join("_") + "_" if @nested_args.any?)}#{plural}_path"
|
@@ -545,7 +541,7 @@ To make a controller that can read all records, specify with --god."
|
|
545
541
|
|
546
542
|
def path_arity
|
547
543
|
res = ""
|
548
|
-
if @nested_args.any? && @
|
544
|
+
if @nested_args.any? && @nested
|
549
545
|
res << nested_objects_arity + ", "
|
550
546
|
end
|
551
547
|
res << "@" + singular
|
@@ -585,7 +581,7 @@ To make a controller that can read all records, specify with --god."
|
|
585
581
|
|
586
582
|
def nest_assignments_operator(top_level = false, leading_comma = false)
|
587
583
|
if @nested_args.any?
|
588
|
-
"#{
|
584
|
+
"#{", " if leading_comma}#{top_level ? nested_assignments_top_level : nested_assignments }"
|
589
585
|
else
|
590
586
|
""
|
591
587
|
end
|
@@ -779,7 +775,8 @@ To make a controller that can read all records, specify with --god."
|
|
779
775
|
show_only: @show_only,
|
780
776
|
singular_class: singular_class,
|
781
777
|
singular: singular,
|
782
|
-
col_identifier: col_identifier
|
778
|
+
col_identifier: col_identifier,
|
779
|
+
ownership_field: @ownership_field
|
783
780
|
)
|
784
781
|
end
|
785
782
|
|
@@ -820,8 +817,8 @@ To make a controller that can read all records, specify with --god."
|
|
820
817
|
end
|
821
818
|
|
822
819
|
def controller_descends_from
|
823
|
-
if defined?(@namespace.titlecase + "::BaseController")
|
824
|
-
@namespace.titlecase + "::BaseController"
|
820
|
+
if defined?(@namespace.titlecase.gsub(" ", "") + "::BaseController")
|
821
|
+
@namespace.titlecase.gsub(" ", "") + "::BaseController"
|
825
822
|
else
|
826
823
|
"ApplicationController"
|
827
824
|
end
|
@@ -4,50 +4,51 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
4
4
|
|
5
5
|
<% unless @auth_identifier == '' || @god %>before_action :authenticate_<%= @auth_identifier %>!<% end %>
|
6
6
|
<% if any_nested? %><% nest_chain = [] %> <% @nested_args.each { |arg|
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
if auth_identifier == arg
|
9
|
+
this_scope = auth_object
|
10
|
+
elsif nest_chain.empty?
|
11
|
+
this_scope = "#{@auth ? auth_object : class_name}.#{arg}s"
|
12
|
+
else
|
13
|
+
this_scope = "#{nest_chain.last}.#{arg}s"
|
14
|
+
end
|
15
|
+
|
16
|
+
nest_chain << arg %>
|
9
17
|
before_action :<%= arg %>
|
10
18
|
<% } %><% end %>
|
11
19
|
before_action :load_<%= singular_name %>, only: [:show, :edit, :update, :destroy]
|
12
20
|
after_action -> { flash.discard }, if: -> { request.format.symbol == :turbo_stream }
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
if eval("#{next_object || class_name}.reflect_on_association(:#{x})").nil?
|
24
|
-
raise "***** Unable to find the association `#{x}` on the class #{next_object || class_name} ..... you probably want to add `belongs_to :#{x}` to the #{next_object || class_name} object?"
|
25
|
-
end
|
26
|
-
next_object = eval("#{next_object || class_name}.reflect_on_association(:#{x})").class_name
|
27
|
-
}
|
28
|
-
root_object = collect_objects.last
|
21
|
+
<% if @nested_args.any? %>
|
22
|
+
def <%= @nested_args[0] %><% if @god
|
23
|
+
next_object = nil
|
24
|
+
collect_objects = @nested_args.reverse.collect {|x|
|
25
|
+
if eval("#{next_object || class_name}.reflect_on_association(:#{x})").nil?
|
26
|
+
raise "***** Unable to find the association `#{x}` on the class #{next_object || class_name} ..... you probably want to add `belongs_to :#{x}` to the #{next_object || class_name} object?"
|
27
|
+
end
|
28
|
+
next_object = eval("#{next_object || class_name}.reflect_on_association(:#{x})").class_name
|
29
|
+
}
|
30
|
+
root_object = collect_objects.last
|
29
31
|
else
|
30
|
-
|
32
|
+
if @nested_args[0] == @auth_identifier
|
33
|
+
root_object = @auth
|
34
|
+
else
|
35
|
+
root_object = @auth + "." + @nested_args[0] + "s"
|
36
|
+
end
|
31
37
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
38
|
+
%><% if !@god && @nested_args[0] == @auth_identifier %>
|
39
|
+
@<%= @nested_args[0] %> ||= <%= root_object %> <% elsif !@god %>
|
40
|
+
@<%= @nested_args[0] %> ||= <%= root_object %>.find(params[:<%= @nested_args[0] %>_id]) <% else %>
|
41
|
+
@<%= @nested_args[0] %> ||= <%= root_object %>.find(params[:<%= @nested_args[0] %>_id]) <% end %>
|
36
42
|
end
|
37
43
|
<% end %>
|
38
|
-
|
39
44
|
<% if any_nested? %><% nest_chain = [@nested_args[0]]; this_scope = @nested_args[0] + 's'; %> <% @nested_args[1..-1].each { |arg|
|
40
45
|
this_scope = "#{nest_chain.last}.#{arg}s"
|
41
46
|
nest_chain << arg
|
42
47
|
%>
|
43
48
|
def <%= arg %>
|
44
49
|
@<%= arg %> ||= <%= this_scope %>.find(params[:<%= arg %>_id])
|
45
|
-
end<% } %>
|
46
|
-
|
47
|
-
<% end %>
|
48
|
-
|
50
|
+
end<% } %> <% end %> <% if !@self_auth %>
|
49
51
|
|
50
|
-
<% if !@self_auth %>
|
51
52
|
def load_<%= singular_name %>
|
52
53
|
@<%= singular_name %> = <%= object_scope.gsub("@",'') %>.find(params[:id])
|
53
54
|
end
|
@@ -57,7 +58,11 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
57
58
|
end<% end %>
|
58
59
|
|
59
60
|
def load_all_<%= plural %>
|
61
|
+
<% if !@self_auth %>
|
60
62
|
@<%= plural_name %> = <%= object_scope.gsub("@",'') %>.page(params[:page])
|
63
|
+
<% else %>
|
64
|
+
@<%= plural_name %> = <%= class_name %>.where(id: <%= auth_object.gsub("@",'') %>.id) # returns iterable even though this <%= singular_name %> is anly allowed access to themselves
|
65
|
+
<% end %>
|
61
66
|
end
|
62
67
|
|
63
68
|
def index
|
@@ -67,10 +72,11 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
67
72
|
end
|
68
73
|
end
|
69
74
|
|
70
|
-
<% if create_action %> def new
|
75
|
+
<% if create_action %> def new
|
76
|
+
<% if ! @god %>
|
71
77
|
@<%= singular_name %> = <%= class_name %>.new(<%= @object_owner_sym %>: <%= @object_owner_eval %>)
|
72
78
|
<% else %>
|
73
|
-
@<%= singular_name %> = <%= class_name %>.new
|
79
|
+
@<%= singular_name %> = <%= class_name %>.new(<% if any_nested? %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)
|
74
80
|
<% end %>
|
75
81
|
respond_to do |format|
|
76
82
|
format.html
|
@@ -78,8 +84,8 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
78
84
|
end
|
79
85
|
|
80
86
|
def create
|
81
|
-
modified_params = modify_date_inputs_on_params(<%=singular_name %>_params.dup<% if
|
82
|
-
@<%=singular_name %> = <%=class_name %>.create(modified_params)
|
87
|
+
modified_params = modify_date_inputs_on_params(<%= singular_name %>_params.dup<% if ! @object_owner_sym.empty? %>.merge!(<%= @object_owner_sym %>: <%= @object_owner_eval %> )<% end %> <%= @auth ? ', ' + @auth : '' %>)
|
88
|
+
@<%=singular_name %> = <%= class_name %>.create(modified_params)
|
83
89
|
|
84
90
|
if @<%= singular_name %>.save
|
85
91
|
flash[:notice] = "Successfully created #{@<%= singular %>.<%= display_class %>}"
|
@@ -1,8 +1,9 @@
|
|
1
1
|
<div class="row">
|
2
|
-
|
2
|
+
<%= all_form_fields %>
|
3
3
|
|
4
4
|
<div class="<%= @layout == "hotglue" ? 'scaffold-cell' : 'col-md-2' %>">
|
5
|
-
<\%= link_to "Cancel", <%= path_helper_plural %>, {class: "btn btn-secondary"} %>
|
5
|
+
<\%= link_to "Cancel", <%= path_helper_plural %>, {class: "btn btn-secondary"} %><% if @no_field_form %>
|
6
|
+
<\%= f.hidden_field "_________" %><% end %>
|
6
7
|
<\%= f.submit "Save", class: "btn btn-primary pull-right" %>
|
7
8
|
</div>
|
8
9
|
</div>
|
@@ -3,6 +3,7 @@
|
|
3
3
|
New <%= singular.titlecase %>
|
4
4
|
</h3>
|
5
5
|
<\%= form_with model: <%= singular %>, url: <%= path_helper_plural %>(<%= nested_objects_arity %>), method: "post" do |f| %>
|
6
|
-
<\%= render partial: "<%= namespace_with_slash + @controller_build_folder %>/form",
|
6
|
+
<\%= render partial: "<%= namespace_with_slash + @controller_build_folder %>/form",
|
7
|
+
locals: { <%= singular %>: <%= singular %> <%= nest_assignments_operator(false, true) %>, f: f} %>
|
7
8
|
<\% end %>
|
8
9
|
<\% end %>
|
@@ -1 +1 @@
|
|
1
|
-
<\%= render partial: "new_form", locals: {<%= singular %>: @<%=singular%>} %>
|
1
|
+
<\%= render partial: "new_form", locals: {<%= singular %>: @<%=singular%><%= nest_assignments_operator(true, true) %>} %>
|
data/lib/hotglue/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hot-glue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Fleetwood-Boldt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.2'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: sass-rails
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: ffaker
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,6 +59,7 @@ executables: []
|
|
73
59
|
extensions: []
|
74
60
|
extra_rdoc_files: []
|
75
61
|
files:
|
62
|
+
- ".circleci/config.yml"
|
76
63
|
- ".github/FUNDING.yml"
|
77
64
|
- ".gitignore"
|
78
65
|
- ".travis.yml"
|
@@ -139,7 +126,7 @@ files:
|
|
139
126
|
- lib/hot-glue.rb
|
140
127
|
- lib/hotglue/engine.rb
|
141
128
|
- lib/hotglue/version.rb
|
142
|
-
homepage: https://
|
129
|
+
homepage: https://jfbcodes.com/p/hot-glue-in-depth-tutorial?utm_source=rubygems.org&utm_campaign=rubygems_link
|
143
130
|
licenses:
|
144
131
|
- Commercial with free option
|
145
132
|
metadata:
|
data/db/schema.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# This file is auto-generated from the current state of the database. Instead
|
2
|
-
# of editing this file, please use the migrations feature of Active Record to
|
3
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
-
#
|
5
|
-
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
-
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
-
# be faster and is potentially less error prone than running all of your
|
8
|
-
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
-
# migrations use external dependencies or application code.
|
10
|
-
#
|
11
|
-
# It's strongly recommended that you check this file into your version control system.
|
12
|
-
|
13
|
-
ActiveRecord::Schema.define(version: 2021_03_06_225506) do
|
14
|
-
|
15
|
-
create_table "abcs", force: :cascade do |t|
|
16
|
-
t.integer "xxx"
|
17
|
-
t.string "yyy"
|
18
|
-
t.integer "dfg_id"
|
19
|
-
t.datetime "created_at", precision: 6, null: false
|
20
|
-
t.datetime "updated_at", precision: 6, null: false
|
21
|
-
end
|
22
|
-
|
23
|
-
create_table "dfg", force: :cascade do |t|
|
24
|
-
t.integer "user_id"
|
25
|
-
t.string "name"
|
26
|
-
t.datetime "created_at", precision: 6, null: false
|
27
|
-
t.datetime "updated_at", precision: 6, null: false
|
28
|
-
end
|
29
|
-
|
30
|
-
create_table "ghis", force: :cascade do |t|
|
31
|
-
t.integer "dfg_id"
|
32
|
-
t.datetime "created_at", precision: 6, null: false
|
33
|
-
t.datetime "updated_at", precision: 6, null: false
|
34
|
-
end
|
35
|
-
|
36
|
-
create_table "jkls", force: :cascade do |t|
|
37
|
-
t.integer "hgi_id"
|
38
|
-
t.datetime "created_at", precision: 6, null: false
|
39
|
-
t.datetime "updated_at", precision: 6, null: false
|
40
|
-
end
|
41
|
-
|
42
|
-
create_table "users", force: :cascade do |t|
|
43
|
-
t.string "email", default: "", null: false
|
44
|
-
t.string "encrypted_password", default: "", null: false
|
45
|
-
t.string "reset_password_token"
|
46
|
-
t.datetime "reset_password_sent_at"
|
47
|
-
t.datetime "remember_created_at"
|
48
|
-
t.datetime "created_at", precision: 6, null: false
|
49
|
-
t.datetime "updated_at", precision: 6, null: false
|
50
|
-
t.index ["email"], name: "index_users_on_email", unique: true
|
51
|
-
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
52
|
-
end
|
53
|
-
|
54
|
-
create_table "xyzs", force: :cascade do |t|
|
55
|
-
t.integer "nothing_id"
|
56
|
-
t.datetime "created_at", precision: 6, null: false
|
57
|
-
t.datetime "updated_at", precision: 6, null: false
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|