hot-glue 0.5.1 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fe06433ca491d353bbc997003fdbc3735fd3bdf35692c35a25237fcaedf73db
4
- data.tar.gz: 42b4b9077a245b75d0878e4bb84e866e8c5b7b61b4f9efd9ea1213678e7def7c
3
+ metadata.gz: a1a6c388f5eaca70bdae8f7aa65eae15330351f534b174a88138d707a8be47c9
4
+ data.tar.gz: c7a91e54babfedb6441ea40349abd85ac3e7a5eb364f1da87087273b7ce56659
5
5
  SHA512:
6
- metadata.gz: 657b12337809a015a32567497a6564afa738e2e29ca4cd4aff142a8d9e5718f15237a69b49b708b164f71d9f98f2b7ed7f21cc1130e45f78306dea4e9a93b00a
7
- data.tar.gz: ac4aed4acb2c70df780f248f024834bf4b055aff18f8438d63415498616a2e8363ff489898f001ee8fbb7885ba99c926d80dbbb659b82f442f6a709bebbaafda
6
+ metadata.gz: 8cd6c967fd9982f1d23885e2c27dffb8e99847d9c24df75880541ca8cf1acf6685025799b4e3473b821a923af4530141d8ab2f23c06dd17295e39e5ef452ad4e
7
+ data.tar.gz: 5b5befaac63a5d23d1163ceb46fefb832d30d2defaeff5efa36ddd1001b28eba0f997955071f95d860e37dfba4f83a9e0b5a9eee356ac6e9e0c577351fc5e3d1
@@ -0,0 +1,16 @@
1
+ name: Test
2
+ on: [ push, pull_request ]
3
+
4
+ jobs:
5
+ build:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v3
9
+ - name: Set up Ruby
10
+ uses: ruby/setup-ruby@v1
11
+ with:
12
+ # Not needed with a .ruby-version file
13
+ ruby-version: 3.1
14
+ # runs 'bundle install' and caches installed gems automatically
15
+ bundler-cache: true
16
+ - run: script/test
data/.gitignore CHANGED
@@ -12,6 +12,8 @@ dump.rdb
12
12
  tmp/
13
13
 
14
14
 
15
+ Gemfile.lock
16
+
15
17
  db/*.sqlite3
16
18
 
17
19
  spec/dummy/app/views/
@@ -21,4 +23,4 @@ spec/dummy/specs/
21
23
  spec/dummy/node_modules/
22
24
  spec/dummy/log/
23
25
 
24
- coverage/
26
+ coverage/
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.2
data/.travis.yml CHANGED
@@ -9,7 +9,7 @@ branches:
9
9
  - main
10
10
 
11
11
 
12
- script: "rake spec"
12
+ script: "script/test"
13
13
 
14
14
  rvm:
15
- - 2.7.2
15
+ - 3.1.2
data/Gemfile CHANGED
@@ -8,13 +8,24 @@ gemspec
8
8
  # not required for your app
9
9
  gem 'sqlite3'
10
10
  gem 'byebug'
11
- gem 'rails'
12
- gem 'devise', require: true
11
+ # gem 'progress_formatter'
13
12
 
14
13
  # for testing
15
- gem "rails-controller-testing", group: [:test]
16
- gem "database_cleaner", group: [:test]
17
- gem "rspec-rails", group: [:test]
18
- gem "rspec_junit_formatter", group: [:test]
19
- gem "factory_bot", group: [:test]
20
14
  gem 'simplecov-rcov'
15
+ gem 'rake'
16
+ gem "rspec-rails"
17
+ gem "factory_bot_rails"
18
+ gem "ffaker"
19
+ gem "capybara"
20
+ gem "selenium-webdriver"
21
+ gem "webdrivers"
22
+
23
+ gem "sprockets-rails"
24
+ gem "importmap-rails"
25
+ gem "stimulus-rails"
26
+ gem "turbo-rails"
27
+
28
+
29
+ gem "puma", "~> 5.0"
30
+
31
+ gem "devise"
data/LICENSE CHANGED
@@ -3,22 +3,8 @@ This software is 'fauxpen source,' which means you can think of it like 'free' a
3
3
 
4
4
  It is definitely 'free' as in Britney.
5
5
 
6
- FOR HOBBYISTS/STUDENTS/TEACHERS/INDIVIDUALS/NON-PROFITS:
7
-
8
- Permission is hereby granted to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
-
10
- Any users of this software agree to work to
11
- 1) dismantle systemic racism
12
- 2) seek justice for black, brown, transgender people, women, and
13
- 3) work towards LGBTQIAA+ representation and inclusion
14
- Organizations using this software agree to center the narratives of black, brown, transgender, and non-advantaged people in the world.
15
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
-
18
- Just sign the pledge at https://heliosdev.shop/hot-glue-license and your email will be granted lifetime usage access.
19
-
20
6
  TO PURCHASE A COMMERCIAL USAGE LICENSE PLEASE VISIT
21
7
  https://heliosdev.shop/hot-glue-license
22
8
 
23
- OR JUST BUY THE TUTORIAL (all purchases come with lifetime license)
24
- https://jfb.teachable.com/p/hot-glue-in-depth-tutorial
9
+ OR PURCHASE THE TUTORIAL (all purchases come with lifetime license)
10
+ https://jfbcodes.com/p/hot-glue-in-depth-tutorial
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- [![Hot Glue](https://circleci.com/gh/jasonfb/hot-glue.svg?style=shield)](https://circleci.com/gh/jasonfb/hot-glue)
2
+ ![Integrated Logo design-639x264](https://user-images.githubusercontent.com/59002/189544688-c1a8226f-9dbd-4758-bc0c-712fc2754cbd.png)
3
3
 
4
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)).
5
5
 
@@ -29,28 +29,24 @@ Hot Glue generates functionality that is quick and dirty. It lets you be crafty.
29
29
 
30
30
 
31
31
  # Get Hot Glue
32
- ## [Licence Only Option Now Available](https://heliosdev.shop/p/hot-glue/?utm_source=github.com&utm_campaign=github_hot_glue_readme_page) **only $50 USD!**
33
- ## [GET THE COURSE TODAY (includes Licence)](https://jfbcodes.com/courses/hot-glue-in-depth-tutorial/?utm_source=github.com&utm_campaign=github_hot_glue_readme_page) **only $60 USD!**
34
32
 
35
- | | |
36
- | ------------- | ------------- |
37
- | ![Teachable-225x225](https://user-images.githubusercontent.com/59002/147857335-a919e095-e6de-4718-8513-736d1f283a0b.png) | Now avaiale on [Teachable](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/?utm_source=github.com&utm_campaign=github_hot_glue_readme_page) |
33
+ ## [GET THE COURSE TODAY](https://jfbcodes.com/courses/hot-glue-in-depth-tutorial/?utm_source=github.com&utm_campaign=github_hot_glue_readme_page) **only $60 USD!**
38
34
 
39
35
 
36
+ [![Hot Glue Course](https://user-images.githubusercontent.com/59002/189544503-6edbcd40-1728-4b13-ac9a-c7772ccb8284.jpg)](https://jfbcodes.com/courses/hot-glue-in-depth-tutorial/?utm_source=github.com&utm_campaign=github_hot_glue_readme_page)
37
+
40
38
  ---
41
39
 
42
40
 
43
- ## NEW GETTING STARTED VIDEO
44
- The getting started video is newly updated with an explanation of the options for **`jsbundling-rails`/`cssbudling-rails`** when creating a new Rails 7 app.
41
+ ## GETTING STARTED VIDEO
45
42
 
46
- Check it out on Youtube at https://www.youtube.com/watch?v=bKjKHMTvzZc
47
43
 
48
- While you're over there could you give my Youtube channel a 'Subscribe'? (look for the RED SUBSCRIBE BUTTON) Thanks so much!
44
+ ~~Check it out on Youtube at https://www.youtube.com/watch?v=bKjKHMTvzZc~~
49
45
 
46
+ While you're over there could you give my Youtube channel a 'Subscribe'? (look for the RED SUBSCRIBE BUTTON)
50
47
 
51
- ---
52
-
53
48
 
49
+ ---
54
50
  ## HOW EASY?
55
51
 
56
52
  ```
@@ -71,40 +67,54 @@ _If you are on Rails 6, see [LEGACY SETUP FOR RAILS 6](https://github.com/jasonf
71
67
 
72
68
  ## 1. Rails 7 New App
73
69
 
74
- There are two ways to create new apps on Rails 7: With or without ImportMap. These instructions prefer the **without Importmap** method, but to help you choose [see this post](https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-7-do-i-need-importmap-rails/)
70
+ To run Turbo (which Hot Glue requires), you must either (1) be running an ImportMap-Rails app, or (2) be running a Node-compiled app using any of JSBundling, Shakapacker, or its alternatives.
71
+
72
+ For reference, see https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-7-do-i-need-importmap-rails/
73
+
74
+ (1) To use ImportMap Rails, start with
75
+ `rails new`
76
+
77
+ If you want Bootstrap, install it following these instructions
75
78
 
76
- `rails new --css=bootstrap --javascript=webpack --database=postgresql`
79
+ (2) To use JSBundling, start with
80
+ `rails new --javascript=jsbundling`
77
81
 
78
- Confirm that both Stimulus and Turbo are working.
79
82
 
80
- **If using JSBundling, make sure to use the new `bin/dev rails` instead of the old `rails server` or else your Webpack will not compile.**
83
+ **If using JSBundling, make sure to use the new `./bin/dev` to start your server instead of the old `rails server` or else your Turbo interactions will not work correctly.**
84
+ If you want Bootstrap, install it following these instructions
81
85
 
82
- For the quick step-by-step guide to help you confirm that both Stimulus and Turbo are working for your new JSBundling-Rails/CSSBunlding-Rails setup [see this post](https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-7-new-app-with-js-bundling-css-bundling/).
86
+ (3) To use Shakapacker,
87
+ `rails new --skip-javascript`
88
+
89
+ If you want Bootstrap, install it following these instructions
83
90
 
84
- (Note that Bootstrap is optional for Hot Glue. Here, I am just showing you the default installation for simplicity.)
85
91
 
86
92
  For the old method of installing Bootstrap [see this post](https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-7-bootstrap/)
87
93
 
88
- Remember, for Rails 6 you must go through the [LEGACY SETUP FOR RAILS 6](https://github.com/jasonfb/hot-glue/README2.md) before continuing.
94
+ Remember, for Rails 6 you must go through the [LEGACY SETUP FOR RAILS 6](https://github.com/jasonfb/hot-glue/blob/main/README2.md) before continuing.
89
95
 
90
96
  ## 2. ADD RSPEC, FACTORY-BOT, AND FFAKER
91
97
 
92
- 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.
98
+ add these 3 gems to your gemfile **inside a group for both :development and :test*.
99
+ Do not add these gems to *only* the :test group or else your Rspec installer and generators will not work correctly.
93
100
  ```
94
- gem 'rspec-rails'
95
- gem 'factory_bot_rails'
96
- gem 'ffaker'
101
+ group :development, :test do
102
+ gem 'rspec-rails'
103
+ gem 'factory_bot_rails'
104
+ gem 'ffaker'
105
+ end
97
106
  ```
98
107
 
108
+ ### Rspec Installer
99
109
  - run `rails generate rspec:install`
100
110
 
111
+ - Because you are not using Minitest, you can delete the `test/` folder at the root of your repository.
112
+
101
113
 
102
114
 
103
115
  ## 3. HOTGLUE INSTALLER
104
116
  Add `gem 'hot-glue'` to your Gemfile & `bundle install`
105
117
 
106
- Purchase a license at https://heliosdev.shop/p/hot-glue
107
-
108
118
  During in installation, you MUST supply a `--layout` flag.
109
119
 
110
120
  ### `--layout` flag (only two options: `hotglue` or `bootstrap`; default is `bootstrap`)
@@ -149,18 +159,8 @@ https://github.com/FortAwesome/font-awesome-sass
149
159
 
150
160
 
151
161
  ## 5. Devise
152
-
153
- (or only use --gd mode, see below)
154
-
155
- Add to your Gemfile
156
-
157
- As of now, Devise for Rails 7 is still not released so you must use **main branch**, like so:
158
-
159
- `gem 'devise', branch: 'main', git: 'https://github.com/heartcombo/devise.git'`
160
-
161
162
  (If you are on Rails 6, you must do ALL of the steps in the Legacy Setup steps. Be sure not to skip **Legacy Step #5** below)
162
-
163
- For Rails 7, be sure you are on the main branch of devise above and your logins should work. (The previously necessary step of disabling turbo shown in Legacy Step #5 is no longer needed. )
163
+ https://github.com/jasonfb/hot-glue/blob/main/README2.md
164
164
 
165
165
  You MUST run the installer FIRST or else you will put your app into a non-workable state:
166
166
  ```
@@ -188,6 +188,19 @@ Those features come by default with Devise, and you'll find the fields for them
188
188
  In this example above, you are creating all of those fields along with a simple 'name' (string) field for your User table.
189
189
 
190
190
 
191
+ !!! Warning: as of 2022-09-19, Devise is still not compatible out-of-the-box with Rails Turbo.
192
+
193
+ To fix this, run
194
+ `rails generate devise:views`
195
+
196
+
197
+ Then manually add `html: {'data-turbo' => "false"}` to all of the Devise forms. You will need to edit the following forms:
198
+ `views/devise/sessions/new.html.erb`, `views/devise/registrations/edit.html.erb`,
199
+ `views/devise/registrations/new.html.erb`, and
200
+
201
+ Add the data-turbo false option in the html key of the form, shown in bold here:
202
+
203
+ form_for(resource, as: resource_name, **html: {'data-turbo' => "false"},** url: session_path(resource_name) ) do |f|
191
204
 
192
205
 
193
206
  ### Hot Glue Installer Notes
@@ -478,9 +491,42 @@ In this case a controller would be generated that would have NO before_action to
478
491
  Please note that this example would produce non-functional code, so you would need to manually fix your controllers to make sure `current_account` is available to the controller.
479
492
 
480
493
 
494
+ ### `--hawk=`
495
+
496
+ Hawk a foreign key that is not the object's owner to within a specified scope.
497
+
498
+ Assuming a Pet belong_to a :human, when building an Appointments scaffold, you can hawk the `pet_id` to the current human's pets. (Whoever is the authentication object.)
499
+
500
+ `--hawk=pet_id`
501
+
502
+ This is covered in [Example #3 in the Hot Glue Tutorial](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38584014)
503
+
504
+ To hawk to a scope that is not the currently authenticated user, use curly braces `{...}` to specify the scope.
505
+
506
+ `--hawk=user_id{current_user.family}`
507
+
508
+ This would hawk the Appointment's `user_id` key to any users who are within the scope of the current_user's family.
509
+
510
+ This is covered in [Example #4 in the Hot Glue Tutorial](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38787505)
511
+
512
+
481
513
  ### `--plural=`
482
514
 
483
- 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)
515
+ You don't need this if the pluralized version is just + "s" of the singular version.
516
+ 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)
517
+
518
+ An better alternative is to define the non-standard plurlizations globally in your app.
519
+
520
+ Make a file at `config/initializers/inflections.rb`
521
+
522
+ # Add new inflection rules using the following format
523
+ ActiveSupport::Inflector.inflections do |inflect|
524
+ inflect.irregular 'clothing', 'clothes'
525
+ inflect.irregular 'human', 'humans'
526
+
527
+
528
+ # the standard pluralization is pretty sexist and will pluralize `human` to `humen`
529
+ end
484
530
 
485
531
 
486
532
  ### `--form-labels-position` (default: `after`; options are **before**, **after**, and **omit**)
@@ -707,10 +753,9 @@ See also setting `--form-labels-position` to control position or omit normal lab
707
753
 
708
754
  ### `--inline-list-labels` (before, after, omit; default: omit)
709
755
 
710
- Determines if field label will appear on the LIST VIEW. NOoe that because Hot Glue has no sparate show route or page,
711
- this affects the `_show` template which is rendered as a partial from the LIST view.
756
+ Determines if field label will appear on the LIST VIEW. Note that because Hot Glue has no separate show route or page, this affects the `_show` template which is rendered as a partial from the LIST view.
712
757
 
713
- Because the labels are already in the heading, this `omit` by default. (Use with `--no-list-heading` to omit the labels in the list heading.)
758
+ Because the labels are already in the heading, this is `omit` by default. (Use with `--no-list-heading` to omit the labels in the list heading.)
714
759
 
715
760
  Use `before` to make the labels come before or `after` to make them come after. See Version 0.5.1 release notes for an example.
716
761
 
@@ -773,13 +818,21 @@ Child portals have the headings omitted automatically (there is a heading identi
773
818
  - Date: displayed as HTML5 date picker
774
819
  - Time: displayed as HTML5 time picker
775
820
  - Boolean: displayed radio buttons yes/ no
776
- - Enum - displayed as a drop-down list (defined the enum values on your model). For Rails 6 see https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
821
+ - Enum - displayed as a drop-down list (defined the enum values on your model).
822
+ - For Rails 6 see https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
777
823
  - AFAIK, you must specify the enum definition both in your model and also in your database migration for both Rails 6 + Rails 7
778
824
 
779
825
 
780
826
  # VERSION HISTORY
781
827
 
782
- #### 2022-03-12 - v0.5.1 - Inline list Labels
828
+ #### 2022-03-23 - v0.5.2 - Hawked Foreign Keys
829
+
830
+ - You can now protect your foreign keys from malicious input and also restrict the scope of drop downs to show only records with the specified access control restriction.
831
+ - [Example #3](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38584014) in the Hot Glue Tutorial shows you how to use the hawk to limit the scope to the logged in user.
832
+ - [Example #4](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38787505) in the Hot Glue Tutorial shows how to hawk to a non-usual scope, the inverse of the current user's belongs_to (that is, hawk the scope to X where current_user `belongs_to :x`)
833
+
834
+
835
+ #### 2022-03-12 - v0.5.1 - Inline List Labels
783
836
 
784
837
  `--inline-list-labels` (default: `after`; options are **before**, **after**, and **omit**)
785
838
 
@@ -838,8 +891,6 @@ Omits the list heading. Note that the listing heading is omitted:
838
891
  3) if the model has `@@table_label_plural = nil`, or
839
892
  4) if you are constructing a nested child portal with only non-optionalized parents.
840
893
 
841
-
842
-
843
894
  #### 2022-02-09 - v0.4.8.1 - Issue with Installer for v0.4.8
844
895
  - There was an issue for the installer for v0.4.8. This new version v0.4.8.1 correts it.
845
896
 
@@ -924,47 +975,33 @@ Omits the list heading. Note that the listing heading is omitted:
924
975
  #### 2021-02-24 - v0.0.1 - first proof of concept release -- basic CRUD works
925
976
 
926
977
 
927
-
928
978
  # HOW THIS GEM IS TESTED
929
979
 
930
- SETUP:
931
- • Run bundle install
932
- • 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
933
-
934
-
935
- The dummy sandbox is found at `spec/dummy`
936
-
937
- 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)
938
-
939
- 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.
980
+ The gem is tested against both generated specs and internal specs. The generated specs are regenerated with the test run, whereas the internal specs live as artifacts in the codebase as you would normally expected specs would.
940
981
 
941
- The DUMMY testing DOES NOT test the actual functionality of the output code (it just tests the functionality of the generation process).
982
+ The generated specs are created with a small set of 'starter seeds' that exercise the gem's featureset. You can examine the setup easily by looking at the contents of `script/test`
942
983
 
984
+ • To setup for testing, start with
985
+ ```
986
+ sudo gem install rails
987
+ sudo gem install rspec
988
+ ```
943
989
 
944
- # DATABASE
945
- being able to run `rake spec` at the root of this repo is achieved using
946
990
  ```
947
- ln -s spec/dummy/db/schema.rb db/schema.rb
991
+ sudo gem install minitest -v 5.1.0
948
992
  ```
949
993
 
950
-
994
+ Unfortunately because of the wrapped nature of the specs, these must be run from globally installed Rubies.
951
995
 
952
- Run rspec as
953
- ```
954
- rake spec
955
- ```
956
- Or with test coverage report:
996
+ Once you've done the above, run `script/test`
957
997
 
958
- ```
959
- COVERGE=on rake spec
998
+ This runs both the **generated specs** and also the **internal specs**. Examine this file for details.
960
999
 
961
- ```
1000
+ To run only the internal specs, use
962
1001
 
963
- --
964
- --
965
-
966
- Test coverage as of 2022-02-14 (v0.4.9)
1002
+ `COVERGE=on rspec spec`
967
1003
 
968
- ![Screen Shot 2022-02-14 at 8 33 29 PM](https://user-images.githubusercontent.com/59002/153975911-30fa9c84-c8d8-49e7-bd5c-e2b958d6f10e.png)
1004
+ Internal Test coverage as of 2022-03-23 (v0.5.2)
969
1005
 
1006
+ ![HG 84 89 coverage report](https://user-images.githubusercontent.com/59002/159719583-a956cfb3-1797-4186-b32c-237ed19e8e2b.png)
970
1007
 
data/README2.md CHANGED
@@ -71,9 +71,7 @@ Edit `devise/registrations/new`, `devise/sessions/new`, `devise/passwords/new` a
71
71
  form_for(resource, as: resource_name, url: session_path(resource_name) ) do |f|
72
72
 
73
73
  add the data-turbo false option in the html key:
74
- ```bigquery
75
74
 
76
- ```
77
75
  form_for(resource, as: resource_name, **html: {'data-turbo' => "false"},** url: session_path(resource_name) ) do |f|
78
76
 
79
77
  This tells Devise to fall back to non-Turbo interaction for the log-in and registration. For the rest of the app, we will use Turbo Rails interactions.
@@ -1,17 +1,14 @@
1
1
  module HotGlue
2
2
  module ControllerHelper
3
-
4
3
  def timezonize(tz)
5
4
  tz = tz.to_i
6
5
  (tz >= 0 ? "+" : "-") + sprintf('%02d',tz.abs) + ":00"
7
6
  end
8
7
 
9
-
10
8
  def datetime_field_localized(form_object, field_name, value, label, timezone = nil )
11
- form_object.text_field(field_name, class: 'form-control',
9
+ form_object.text_field(field_name, class: 'form-control',
12
10
  type: 'datetime-local',
13
- value: date_to_current_timezone(value, timezone))
14
- + timezonize(timezone)
11
+ value: date_to_current_timezone(value, timezone)) + timezonize(timezone)
15
12
  end
16
13
 
17
14
 
@@ -24,8 +21,7 @@ module HotGlue
24
21
  def time_field_localized(form_object, field_name, value, label, timezone = nil )
25
22
  form_object.text_field(field_name, class: 'form-control',
26
23
  type: 'time',
27
- value: date_to_current_timezone(value, timezone))
28
- + timezonize(timezone)
24
+ value: date_to_current_timezone(value, timezone)) + timezonize(timezone)
29
25
 
30
26
  end
31
27
 
@@ -36,40 +32,30 @@ module HotGlue
36
32
  else
37
33
  server_timezone
38
34
  end
39
- elsif true
40
- server_timezone
41
- # elsif defined?(controller) == "method"
42
- # # controller.try(:current_timezone)
43
- # elsif self.class.ancestors.include?(ApplicationController)
44
- # self.try(:current_timezone)
45
35
  else
46
- puts "no method current_user is available; please implement/override the method current_timezone IN YOUR CONTROLLER"
47
- exit
36
+ server_timezone
48
37
  end
49
38
  end
50
39
 
51
- def server_timezone
52
- Time.now.strftime("%z").to_i/100
53
- end
54
-
55
40
  def date_to_current_timezone(date, timezone = nil)
56
41
  # if the timezone is nil, use the server date'
42
+
57
43
  if timezone.nil?
58
44
  timezone = Time.now.strftime("%z").to_i/100
59
45
  end
60
46
 
61
47
  return nil if date.nil?
62
48
 
63
- begin
64
- return date.in_time_zone(timezone).strftime("%Y-%m-%dT%H:%M")
65
- rescue
66
- return nil
67
- end
49
+ return date.in_time_zone(timezone).strftime("%Y-%m-%dT%H:%M")
50
+ # begin
51
+ #
52
+ # rescue
53
+ # return nil
54
+ # end
68
55
  end
69
56
 
70
-
71
-
72
57
  def modify_date_inputs_on_params(modified_params, current_user_object = nil)
58
+
73
59
  use_timezone = (current_user_object.try(:timezone)) || Time.now.strftime("%z")
74
60
 
75
61
  modified_params = modified_params.tap do |params|
@@ -86,5 +72,27 @@ module HotGlue
86
72
  end
87
73
  modified_params
88
74
  end
75
+
76
+
77
+ def hawk_params(hawk_schema, modified_params)
78
+ @hawk_alarm = ""
79
+ hawk_schema.each do |hawk_key,hawk_definition|
80
+ hawk_root = hawk_definition[0]
81
+ hawk_scope = hawk_definition[1]
82
+ begin
83
+ eval("hawk_root.#{hawk_scope}").find(modified_params[hawk_key.to_s])
84
+ rescue ActiveRecord::RecordNotFound => e
85
+ @hawk_alarm << "You aren't allowed to set #{hawk_key.to_s} to #{modified_params[hawk_key.to_s]}. "
86
+ modified_params.tap { |hs| hs.delete(hawk_key.to_s) }
87
+ end
88
+ end
89
+ modified_params
90
+ end
91
+
92
+ private
93
+
94
+ def server_timezone
95
+ Time.now.strftime("%z").to_i/100
96
+ end
89
97
  end
90
98
  end
data/config/database.yml CHANGED
@@ -1,11 +1,25 @@
1
- development:
1
+ # SQLite. Versions 3.8.0 and up are supported.
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem "sqlite3"
6
+ #
7
+ default: &default
2
8
  adapter: sqlite3
3
- database: ../spec/dummy/db/development.sqlite3
4
- pool: 5
9
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
5
10
  timeout: 5000
6
11
 
12
+ development:
13
+ <<: *default
14
+ database: dummy/db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
7
19
  test:
8
- adapter: sqlite3
9
- database: ../spec/dummy/db/test.sqlite3
10
- pool: 5
11
- timeout: 5000
20
+ <<: *default
21
+ database: dummy/db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: dummy/db/production.sqlite3