common_core_js 0.0.2.alpha → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.generators +8 -0
  3. data/.gitignore +14 -0
  4. data/.rakeTasks +7 -0
  5. data/Gemfile +15 -0
  6. data/Gemfile.lock +175 -0
  7. data/LICENSE +10 -0
  8. data/README.md +288 -0
  9. data/Rakefile +32 -0
  10. data/app/assets/config/common_core_js_manifest.js +1 -0
  11. data/app/assets/images/common_core_js/.keep +0 -0
  12. data/app/assets/stylesheets/common_core_js/application.css +15 -0
  13. data/app/assets/stylesheets/common_core_js/common_core.scss +43 -0
  14. data/app/controllers/common_core_js/application_controller.rb +5 -0
  15. data/app/helpers/common_core_js/application_helper.rb +4 -0
  16. data/app/helpers/common_core_js/generator_helper.rb +0 -0
  17. data/app/jobs/common_core_js/application_job.rb +4 -0
  18. data/app/mailers/common_core_js/application_mailer.rb +6 -0
  19. data/app/models/common_core_js/application_record.rb +5 -0
  20. data/app/views/common/_common_create.js.erb +1 -1
  21. data/app/views/common/_common_destroy.js.erb +1 -1
  22. data/app/views/common/_common_index.js.erb +1 -1
  23. data/app/views/common/_common_new_form.haml +2 -2
  24. data/app/views/common/_common_update.js.erb +1 -1
  25. data/app/views/layouts/common_core_js/application.html.erb +15 -0
  26. data/bin/rails +14 -0
  27. data/common_core_js.gemspec +70 -0
  28. data/config/routes.rb +2 -0
  29. data/lib/.DS_Store +0 -0
  30. data/lib/common_core_js.rb +5 -6
  31. data/lib/common_core_js/engine.rb +5 -0
  32. data/lib/common_core_js/version.rb +3 -0
  33. data/lib/generators/common_core/USAGE +2 -4
  34. data/lib/generators/common_core/install_generator.rb +23 -0
  35. data/lib/generators/common_core/scaffold_generator.rb +300 -35
  36. data/lib/generators/common_core/templates/_edit.haml +1 -1
  37. data/lib/generators/common_core/templates/_form.haml +1 -0
  38. data/lib/generators/common_core/templates/_line.haml +3 -0
  39. data/lib/generators/common_core/templates/_list.haml +1 -1
  40. data/lib/generators/common_core/templates/_new.haml +3 -1
  41. data/lib/generators/common_core/templates/all.haml +4 -0
  42. data/lib/generators/common_core/templates/common_core.js +37 -0
  43. data/lib/generators/common_core/templates/common_core.scss +0 -0
  44. data/lib/generators/common_core/templates/controller.rb +21 -10
  45. data/lib/generators/common_core/templates/controller_spec.rb +110 -0
  46. data/lib/generators/common_core/templates/edit.js.erb +1 -1
  47. data/lib/generators/common_core/templates/update.js.erb +1 -1
  48. data/lib/tasks/common_core_js_tasks.rake +7 -0
  49. metadata +132 -38
  50. data/app/assets/config/manifest.js +0 -3
  51. data/lib/version.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1409fc4b861506634c105233ecd7562a94d6cd4256aeee556ea99763eb54e40
4
- data.tar.gz: d8a0ae1dfb94af15ee0925758bec9dada9fe96631a41fae2a70b545bf2df3852
3
+ metadata.gz: b3c68ef2ddc0f4e98ca5b54d0c646a918b2f70d091fe89db9951a61879af34d2
4
+ data.tar.gz: 5ea645a245a197d42dabf6f697a7f94e5227d6c8416da47d8dfe875fdc28cbea
5
5
  SHA512:
6
- metadata.gz: b28c45efde7fd2c13c807a963b72d1ebd44d998a9cff1ed57ac8ab9484c4fe377e194b98413e8a5870009f3172c02132ec6d2ec8eaa5194edabe321a0697c896
7
- data.tar.gz: b90df55216345e8c6069496ea5ebaca4b4882a77e0ca9a2d5c694c085107ab1015ea5397d3cf95b33167ffe7322c8cc325bbe74f8e08e8485291f7e33fcea033
6
+ metadata.gz: 7490de5c8f29a6a80960c50ecbb37a02122cafcc96b345c200f1cdc4cb3cf5f50f15e2fb4609f6f4a920b814c9fb123b9024a8d226a1e0f225bebe5246fe9cbb
7
+ data.tar.gz: fccfc40f5851a9a0bffdc5410085073afa8798320b4abf7a770c1dd7e3070ff871e341ba613f67b7afed11ea2a69c9c685dd130b41bc301ca89386490c5dd77a
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Reorder generators
5
+ 2. Remove generators
6
+ 3. Add installed generators
7
+ To add new installed generators automatically delete this file and reload the project.
8
+ --><GeneratorsGroup><Generator name="controller" /><Generator name="integration_test" /><Generator name="mailer" /><Generator name="migration" /><Generator name="model" /><Generator name="observer" /><Generator name="plugin" /><Generator name="resource" /><Generator name="scaffold" /><Generator name="session_migration" /></GeneratorsGroup></Settings>
@@ -0,0 +1,14 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/db/*.sqlite3-journal
6
+ test/dummy/db/*.sqlite3-*
7
+ test/dummy/log/*.log
8
+ test/dummy/storage/
9
+ test/dummy/tmp/
10
+ .byebug_history
11
+
12
+ .idea/
13
+ *.gem
14
+ .DS_Store
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in common_core_js.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ # Declare any dependencies that are still in development here instead of in
10
+ # your gemspec. These might include edge Rails or gems from your path or
11
+ # Git. Remember to move these dependencies to your gemspec before releasing
12
+ # your gem to rubygems.org.
13
+
14
+ # To use a debugger
15
+ # gem 'byebug', group: [:development, :test]
@@ -0,0 +1,175 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ common_core_js (0.1.1)
5
+ haml-rails
6
+ kaminari
7
+ rails
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (6.0.3.2)
13
+ actionpack (= 6.0.3.2)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ actionmailbox (6.0.3.2)
17
+ actionpack (= 6.0.3.2)
18
+ activejob (= 6.0.3.2)
19
+ activerecord (= 6.0.3.2)
20
+ activestorage (= 6.0.3.2)
21
+ activesupport (= 6.0.3.2)
22
+ mail (>= 2.7.1)
23
+ actionmailer (6.0.3.2)
24
+ actionpack (= 6.0.3.2)
25
+ actionview (= 6.0.3.2)
26
+ activejob (= 6.0.3.2)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.0.3.2)
30
+ actionview (= 6.0.3.2)
31
+ activesupport (= 6.0.3.2)
32
+ rack (~> 2.0, >= 2.0.8)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.0.3.2)
37
+ actionpack (= 6.0.3.2)
38
+ activerecord (= 6.0.3.2)
39
+ activestorage (= 6.0.3.2)
40
+ activesupport (= 6.0.3.2)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.0.3.2)
43
+ activesupport (= 6.0.3.2)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.0.3.2)
49
+ activesupport (= 6.0.3.2)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.0.3.2)
52
+ activesupport (= 6.0.3.2)
53
+ activerecord (6.0.3.2)
54
+ activemodel (= 6.0.3.2)
55
+ activesupport (= 6.0.3.2)
56
+ activestorage (6.0.3.2)
57
+ actionpack (= 6.0.3.2)
58
+ activejob (= 6.0.3.2)
59
+ activerecord (= 6.0.3.2)
60
+ marcel (~> 0.3.1)
61
+ activesupport (6.0.3.2)
62
+ concurrent-ruby (~> 1.0, >= 1.0.2)
63
+ i18n (>= 0.7, < 2)
64
+ minitest (~> 5.1)
65
+ tzinfo (~> 1.1)
66
+ zeitwerk (~> 2.2, >= 2.2.2)
67
+ builder (3.2.4)
68
+ concurrent-ruby (1.1.6)
69
+ crass (1.0.6)
70
+ erubi (1.9.0)
71
+ erubis (2.7.0)
72
+ globalid (0.4.2)
73
+ activesupport (>= 4.2.0)
74
+ haml (5.1.2)
75
+ temple (>= 0.8.0)
76
+ tilt
77
+ haml-rails (2.0.1)
78
+ actionpack (>= 5.1)
79
+ activesupport (>= 5.1)
80
+ haml (>= 4.0.6, < 6.0)
81
+ html2haml (>= 1.0.1)
82
+ railties (>= 5.1)
83
+ html2haml (2.2.0)
84
+ erubis (~> 2.7.0)
85
+ haml (>= 4.0, < 6)
86
+ nokogiri (>= 1.6.0)
87
+ ruby_parser (~> 3.5)
88
+ i18n (1.8.3)
89
+ concurrent-ruby (~> 1.0)
90
+ kaminari (1.2.1)
91
+ activesupport (>= 4.1.0)
92
+ kaminari-actionview (= 1.2.1)
93
+ kaminari-activerecord (= 1.2.1)
94
+ kaminari-core (= 1.2.1)
95
+ kaminari-actionview (1.2.1)
96
+ actionview
97
+ kaminari-core (= 1.2.1)
98
+ kaminari-activerecord (1.2.1)
99
+ activerecord
100
+ kaminari-core (= 1.2.1)
101
+ kaminari-core (1.2.1)
102
+ loofah (2.6.0)
103
+ crass (~> 1.0.2)
104
+ nokogiri (>= 1.5.9)
105
+ mail (2.7.1)
106
+ mini_mime (>= 0.1.1)
107
+ marcel (0.3.3)
108
+ mimemagic (~> 0.3.2)
109
+ method_source (1.0.0)
110
+ mimemagic (0.3.5)
111
+ mini_mime (1.0.2)
112
+ mini_portile2 (2.4.0)
113
+ minitest (5.14.1)
114
+ nio4r (2.5.2)
115
+ nokogiri (1.10.9)
116
+ mini_portile2 (~> 2.4.0)
117
+ rack (2.2.3)
118
+ rack-test (1.1.0)
119
+ rack (>= 1.0, < 3)
120
+ rails (6.0.3.2)
121
+ actioncable (= 6.0.3.2)
122
+ actionmailbox (= 6.0.3.2)
123
+ actionmailer (= 6.0.3.2)
124
+ actionpack (= 6.0.3.2)
125
+ actiontext (= 6.0.3.2)
126
+ actionview (= 6.0.3.2)
127
+ activejob (= 6.0.3.2)
128
+ activemodel (= 6.0.3.2)
129
+ activerecord (= 6.0.3.2)
130
+ activestorage (= 6.0.3.2)
131
+ activesupport (= 6.0.3.2)
132
+ bundler (>= 1.3.0)
133
+ railties (= 6.0.3.2)
134
+ sprockets-rails (>= 2.0.0)
135
+ rails-dom-testing (2.0.3)
136
+ activesupport (>= 4.2.0)
137
+ nokogiri (>= 1.6)
138
+ rails-html-sanitizer (1.3.0)
139
+ loofah (~> 2.3)
140
+ railties (6.0.3.2)
141
+ actionpack (= 6.0.3.2)
142
+ activesupport (= 6.0.3.2)
143
+ method_source
144
+ rake (>= 0.8.7)
145
+ thor (>= 0.20.3, < 2.0)
146
+ rake (13.0.1)
147
+ ruby_parser (3.14.2)
148
+ sexp_processor (~> 4.9)
149
+ sexp_processor (4.15.0)
150
+ sprockets (4.0.2)
151
+ concurrent-ruby (~> 1.0)
152
+ rack (> 1, < 3)
153
+ sprockets-rails (3.2.1)
154
+ actionpack (>= 4.0)
155
+ activesupport (>= 4.0)
156
+ sprockets (>= 3.0.0)
157
+ temple (0.8.2)
158
+ thor (1.0.1)
159
+ thread_safe (0.3.6)
160
+ tilt (2.0.10)
161
+ tzinfo (1.2.7)
162
+ thread_safe (~> 0.1)
163
+ websocket-driver (0.7.2)
164
+ websocket-extensions (>= 0.1.0)
165
+ websocket-extensions (0.1.5)
166
+ zeitwerk (2.3.1)
167
+
168
+ PLATFORMS
169
+ ruby
170
+
171
+ DEPENDENCIES
172
+ common_core_js!
173
+
174
+ BUNDLED WITH
175
+ 2.1.4
data/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ 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:
2
+
3
+ Any users of this software agree to work to dismantle systemic racism, seek justice for black, brown, transgender people, women, and LTBQIAA+ representation and inclusion.
4
+
5
+ Organizations using this software agree to center the narratives of black, brown, and transgender people people.
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ 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.
10
+
@@ -0,0 +1,288 @@
1
+ # Common Core Scaffold Builder & Rapid Prototype Developer
2
+
3
+
4
+ Yes, it's a Rails scaffoling builder. Yes, it builds scaffolding quickly and easily. Yes, it's similar to all the other Rails scaffold builders.
5
+
6
+ Yes, it's opinionated. Yes, it's metaprogramming. A lot of metaprogramming. Ruby on Ruby. Ruby on Javascript. It's like a whole fun pile of metaprogramming.
7
+
8
+ No, I would not use this to build an intricate app. Yes, it's a great tool for prototyping. Yes, I think prototyping is a lost art.
9
+
10
+
11
+ = THE SALES PITCH:
12
+ * Build plug-and-play scaffolding mixing HAML with jQuery-based Javascript
13
+ * Automatically Reads Your Models (make them before building your scaffolding!)
14
+ * Excellent for CRUD, lists with pagination, searching, sorting.
15
+ * Wonderful for prototyping.
16
+ * Plays nicely with Devise, Kaminari, Haml-Rails, Rspec.
17
+ * Create specs autoamatically along with the controllers.
18
+ * Nest your routes model-by-model for built-in poor man's authentication
19
+ * Throw the scaffolding away when your app is ready to graduate to its next phase.
20
+
21
+
22
+ = HOW EASY?
23
+
24
+
25
+ ```
26
+ rails generate common_core:scaffold Thing
27
+ ```
28
+
29
+ = TO INSTALL
30
+
31
+ - Add common_core_js to your Gemfile
32
+
33
+ - Install jQuery (required)
34
+
35
+ - Install Bootstrap (optional)
36
+
37
+ - Install Devise or implement your own authentication
38
+
39
+ - Unless you want to bypass specs, you'll also want Rspec (rspec-rails), factory_bot_rails, and shoulda-matchers
40
+
41
+
42
+ ## Options
43
+
44
+ Note that the arguments are not preceeded by dashes and are followed by equal sign and the input you are giving.
45
+
46
+ Flags take two dashes (--) and do not take any value.
47
+
48
+ ### First Argument
49
+
50
+ TitleCase class name of the thing you want to build a scaffoling for.
51
+
52
+ ### `namespace=`
53
+
54
+ pass `namespace=` as a flag to denote a namespace to apply to the Rails path helpers
55
+
56
+
57
+ `rails generate common_core:scaffold Thing namespace=dashboard`
58
+
59
+ This produces several views at `app/views/dashboard/things/` and a controller at`app/controllers/dashboard/things_controller.rb`
60
+
61
+ The controller looks like so:
62
+
63
+ ```
64
+ class Dashboard::ThingsController < ApplicationController
65
+ before_action :authenticate_user!
66
+ before_action :load_thing, only: [:show, :edit, :update, :destroy]
67
+ def load_thing
68
+ @thing = current_user.things.find(params[:id])
69
+ end
70
+ ...
71
+ end
72
+
73
+ ```
74
+
75
+
76
+ ### `nest=`
77
+
78
+ pass `nest=` as a flag to denote a nested resources
79
+
80
+
81
+ `rails generate common_core:scaffold Line nest=invoice`
82
+
83
+ In this example, it is presumed that the current user has_many :invoices, and that invoices have many :lines
84
+
85
+
86
+ For multi-level nesting use slashes to separate your levels of nesting. Remember, you should match what you have in your routes.rb file.
87
+
88
+ ```
89
+ resources :invoices do
90
+ resources :lines do
91
+ resources :charge
92
+ end
93
+ end
94
+
95
+ ```
96
+ 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
97
+
98
+
99
+ To generate scaffold:
100
+ `rails generate common_core:scaffold Charge nest=invoice/line`
101
+
102
+ 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:
103
+
104
+ In the example above, @invoice will be loaded from
105
+
106
+ `@invoice = current_user.invoices.find(params[:invoice_id])`
107
+
108
+ Then, @line will be loaded
109
+
110
+ `@line = @invoice.lines.find(params[:line_id])`
111
+
112
+ Then, finally the @charge will be loaded
113
+
114
+ `@charge = @line.charges.find(params[:id])`
115
+
116
+ 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).
117
+
118
+ 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).
119
+
120
+ Your customers can delete their own objects by default (may be a good idea or a bad idea for you). If you don't want that, you should strip out the delete actions off the controllers.
121
+
122
+
123
+ ### `auth=`
124
+
125
+ By default, it will be assumed you have a `current_user` for your user authentication. This will be treated as the "authentication root" for the "poor man's auth" explained above.
126
+
127
+ 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.
128
+
129
+ Of course this is a sloppy way to do authentication, and can easily leave open endpoints your real users shouldn't have access to.
130
+
131
+ 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.
132
+
133
+ If you use Devise, you probably already have a `current_user` method available in your controllers. If you don't use Devise, you can implement it in your ApplicationController.
134
+
135
+ If you use a different object other than "User" for authentication, override using the `auth` flag.
136
+
137
+ `rails generate common_core:scaffold Thing auth=current_account`
138
+
139
+ You will note that in this example it is presumed that the Account object will have an association for `things`
140
+
141
+ It is also presumed that when viewing their own dashboard of things, the user will want to see ALL of their associated things.
142
+
143
+ If you supply nesting (see below), your nest chain will automatically begin with your auth root object (see nesting)
144
+
145
+
146
+
147
+
148
+ ### `auth_identifier=`
149
+
150
+ Your controller will call a method authenticate_ (AUTH IDENTIFIER) bang, like:
151
+
152
+ `authenticate_user!`
153
+
154
+ Before all of the controller actions. If you leave this blank, it will default to using the variable name supplied by auth with "current_" stripped away.
155
+ (This is setup for devise.)
156
+
157
+ Be sure to implement the following method in your ApplicationController or some other method. Here's a quick example using Devise. You will note in the code below, user_signed_in? is implemented when you add Devise methods to your User table.
158
+
159
+ As well, the `after_sign_in_path_for(user)` here is a hook for Devise also that provides you with after login redirect to the page where the user first intended to go.
160
+
161
+ ```
162
+ def authenticate_user!
163
+ if ! user_signed_in?
164
+ session['user_return_to'] = request.path
165
+ redirect_to new_user_registration_path
166
+ end
167
+ end
168
+
169
+ def after_sign_in_path_for(user)
170
+ session['user_return_to'] || account_url(user)
171
+ end
172
+ ```
173
+
174
+
175
+ The default (do not pass `auth_identifier=`) will match the `auth` (So if you use 'account' as the auth, `authenticate_account!` will get invoked from your generated controller; the default is always 'user', so you can leave both auth and auth_identifier off if you want 'user')
176
+
177
+
178
+ `rails generate common_core:scaffold Thing auth=current_account auth_identifier=login`
179
+ In this example, the controller produced with:
180
+ ```
181
+ before_action :authenticate_login!
182
+ ```
183
+ However, the object graph anchors would continue to start from current_account. That is,
184
+ ```
185
+ @thing = current_account.things.find(params[:id])
186
+ ```
187
+
188
+ Use empty string to **turn this method off**:
189
+ `rails generate common_core:scaffold Thing auth=current_account auth_identifier=''`
190
+
191
+ In this case a controller would be generated that would have NO before_action to authenticate the account, but it would still treat the current_account as the auth root for the purpose of loading the objects.
192
+
193
+ Please note that this example would product non-functional code, so you would need to manually fix your controllers to make sure `current_account` is available to the controller.
194
+
195
+
196
+ ### `plural=`
197
+
198
+ 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)
199
+
200
+
201
+ ### `--god`
202
+
203
+ Use this flag to create controllers with no root authentication. You can still use an auth_identifier, which can be useful for a meta-leval authentication to the controoler.
204
+
205
+ For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use --god flag
206
+
207
+ In God mode, the objects are loaded directly from the base class (these controllers have full access)
208
+ ```
209
+ def load_thing
210
+ @thing = Thing.find(params[:id])
211
+ end
212
+
213
+ ```
214
+
215
+ ### `--with-index`
216
+
217
+ By default no master index views get produced. Use this flag to produce an index view.
218
+
219
+ The index views simply include the _list partial but pass them a query to use:
220
+
221
+ `= render partial: "list", locals: {things: Thing.order("created_at DESC").page(1)}`
222
+
223
+ You will note that unlike other scaffold you may have seen, the "all" view is found at
224
+ ```
225
+ all.haml
226
+ ```
227
+
228
+ Common core generate ONLY this top-level (non-partial) HAML file, relying on Rails partials to do the rest. This lets us get little fancy with reloading and re-rendering, and provides for a smooth consistent starting point for you to customize the views.
229
+
230
+ The intention is that you DO NOT generate any all.haml views, because you will probably be building a dashboard that composites several different tables into a single page.
231
+
232
+ When you do that, load the list views from the build scaffolding to define the different sections of your page
233
+
234
+ ```
235
+ = render partial: "dashboard/things/list", locals: {things: current_user.things.order("created_at DESC").page(1)}
236
+ ```
237
+
238
+ Because it's rare that you actually want to build a page that is just a list of one table, the index views are not generate by default.
239
+
240
+
241
+ ### `--specs-only`
242
+
243
+ Produces ONLY the controller spec file, nothing else.
244
+
245
+
246
+ ### `--no-specs`
247
+
248
+ Produces all the files except the spec file.
249
+
250
+
251
+
252
+
253
+
254
+ # TROUBLESHOOTING
255
+
256
+ ## NoMethodError in HellosController#index undefined method `authenticate_user!' for #<HellosController:0x00007fcc2decf828> Did you mean? authenticate_with_http_digest
257
+
258
+ --> Install Devise or implement current_user method on your controller or use with auth= and/or auth_identifier= to specify how you want to authenticate your user.
259
+
260
+
261
+ ## Uncaught ReferenceError: $ is not defined
262
+
263
+ --> Install Jquery + Rails UJS
264
+ `yarn add jquery`
265
+ `yarn add @rails/ujs`
266
+
267
+ Add to application.js
268
+ ```
269
+ require("jquery")
270
+ ```
271
+
272
+ And add to config/webpack/environment.js
273
+
274
+ ```
275
+ const { environment } = require('@rails/webpacker')
276
+
277
+ const webpack = require('webpack')
278
+ environment.plugins.prepend('Provide',
279
+ new webpack.ProvidePlugin({
280
+ $: 'jquery/src/jquery',
281
+ jQuery: 'jquery/src/jquery',
282
+ Rails: ['@rails/ujs']
283
+ })
284
+ )
285
+
286
+ module.exports = environment
287
+
288
+ ```