common_core_js 0.0.2.alpha → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +10 -0
- data/README.md +175 -0
- data/Rakefile +32 -0
- data/app/assets/config/common_core_js_manifest.js +1 -0
- data/app/assets/stylesheets/common_core_js/application.css +15 -0
- data/app/controllers/common_core_js/application_controller.rb +5 -0
- data/app/helpers/common_core_js/application_helper.rb +4 -0
- data/app/jobs/common_core_js/application_job.rb +4 -0
- data/app/mailers/common_core_js/application_mailer.rb +6 -0
- data/app/models/common_core_js/application_record.rb +5 -0
- data/app/views/common/_common_create.js.erb +1 -1
- data/app/views/common/_common_destroy.js.erb +1 -1
- data/app/views/common/_common_index.js.erb +1 -1
- data/app/views/common/_common_new_form.haml +2 -2
- data/app/views/common/_common_update.js.erb +1 -1
- data/app/views/layouts/common_core_js/application.html.erb +15 -0
- data/config/routes.rb +2 -0
- data/lib/common_core_js.rb +5 -6
- data/lib/common_core_js/engine.rb +5 -0
- data/lib/common_core_js/version.rb +3 -0
- data/lib/generators/common_core/scaffold_generator.rb +19 -7
- data/lib/generators/common_core/templates/_list.haml +1 -1
- data/lib/generators/common_core/templates/_new.haml +3 -1
- data/lib/generators/common_core/templates/controller.rb +19 -6
- data/lib/tasks/common_core_js_tasks.rake +4 -0
- metadata +38 -6
- data/app/assets/config/manifest.js +0 -3
- data/lib/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52d92bafcfe6f844d7d1d9eb69dda3a9b1740690a7bc079532f6777d33856451
|
4
|
+
data.tar.gz: 8c9a49ccb3baacee68bac8b3c04b657949b685e52683fbd07be57026d3c54ea8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31731a78478bc117b93478fd0fb3179f2ea2596289619d16caadd94bb8c23d3e0e4f256d69b09a56eaf0925ee0605395cc0938cf1b2372bb57aa46614618ed98
|
7
|
+
data.tar.gz: a292d839273003ba32c6b5456c13ee1d6f912ee213c545272fb655d2d0ddef6a5a9add40717beda86559151104d3cef06d1654d437844904d67898d06e5649e7
|
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 in American society, seek justice for black, brown, trans-people, women, and LTBQIAA+ representation and inclusion.
|
4
|
+
|
5
|
+
Organizations using this software agree to center the narratives of black, brown, and trans people in the self vision and imagary.
|
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
|
+
|
data/README.md
ADDED
@@ -0,0 +1,175 @@
|
|
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
|
+
```
|
12
|
+
rails generate common_core:scaffold Thing
|
13
|
+
```
|
14
|
+
|
15
|
+
## Options
|
16
|
+
|
17
|
+
Note that the arguments are not preceeded by dashes and are followed by equal sign and the input you are giving.
|
18
|
+
|
19
|
+
Flags take two dashes (--) and do not take any value.
|
20
|
+
|
21
|
+
### First Argument
|
22
|
+
|
23
|
+
TitleCase class name of the thing you want to build a scaffoling for.
|
24
|
+
|
25
|
+
### namespace=
|
26
|
+
|
27
|
+
pass `namespace=` as a flag to denote a namespace to apply to the Rails path helpers
|
28
|
+
|
29
|
+
|
30
|
+
`rails generate common_core:scaffold GetEmailsRule namespace=dashboard`
|
31
|
+
|
32
|
+
### nest=
|
33
|
+
|
34
|
+
pass `nest=` as a flag to denote a nested resources
|
35
|
+
|
36
|
+
|
37
|
+
`rails generate common_core:scaffold Lineitem nest=invoice`
|
38
|
+
|
39
|
+
For multi-level nesting use slashes to separate your levels of nesting. Remember, you should match what you have in your routes.rb file.
|
40
|
+
|
41
|
+
resources :invoices do
|
42
|
+
resources :lines do
|
43
|
+
resources :charges
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
`rails generate common_core:scaffold Charge nest=invoice/line`
|
49
|
+
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:
|
50
|
+
|
51
|
+
In the example above, @invoice will be loaded from
|
52
|
+
|
53
|
+
@invoice = current_user.invoices.find(params[:invoice_id])
|
54
|
+
|
55
|
+
Then, @line will be loaded
|
56
|
+
|
57
|
+
@line = @invoice.lines.find(params[:line_id])
|
58
|
+
|
59
|
+
Then finally the @charge will be loaded
|
60
|
+
|
61
|
+
@charge = @line.charges.find(params[:id])
|
62
|
+
|
63
|
+
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 errros because the objects will not be found in the assocaited relationships.
|
64
|
+
|
65
|
+
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).
|
66
|
+
|
67
|
+
Your customers can delete their own objects by default (may be a good idea or a bay idea for you). If you don't want that, you should strip out the delete actions off the controllers.
|
68
|
+
|
69
|
+
|
70
|
+
### auth=
|
71
|
+
|
72
|
+
By default, it will be assumed you have a `current_user` for your user authentication. This will be treated as the "authentication root" for what is fundamentally "poor man's auth."
|
73
|
+
|
74
|
+
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.
|
75
|
+
|
76
|
+
Of course this is a sloppy way to do authentication, and can easily leave open endpoints your real users shouldn't have access to.
|
77
|
+
|
78
|
+
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.
|
79
|
+
|
80
|
+
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.
|
81
|
+
|
82
|
+
If you use a different object other than "User" for authentication, override using the `auth` flag.
|
83
|
+
|
84
|
+
`rails generate common_core:scaffold Thing auth=current_account`
|
85
|
+
|
86
|
+
You will note that in this example it is presumed that the Account object will have an association for `things`
|
87
|
+
|
88
|
+
It is also presumed that when viewing their own dashboard of things, the user will want to see ALL of their associated things.
|
89
|
+
|
90
|
+
If you supply nesting (see below), your nest chain will automatically begin with your auth root object (see nesting)
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
### auth_identifier=
|
96
|
+
|
97
|
+
Your controller will call a method authenticate_ (AUTH IDNETIFIER) bang, like:
|
98
|
+
|
99
|
+
authenticate_user!
|
100
|
+
|
101
|
+
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.
|
102
|
+
(This is setup for devise.)
|
103
|
+
|
104
|
+
Leave blank for default, which is to match the auth.
|
105
|
+
|
106
|
+
`rails generate common_core:scaffold Thing auth=current_account auth_identifier=login`
|
107
|
+
In this example, the controller produced with have:
|
108
|
+
before_action :authenticate_login!
|
109
|
+
|
110
|
+
|
111
|
+
Use empty string to turn this method off:
|
112
|
+
`rails generate common_core:scaffold Thing auth=current_account auth_identifier=''`
|
113
|
+
|
114
|
+
|
115
|
+
### plural=
|
116
|
+
|
117
|
+
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)
|
118
|
+
|
119
|
+
|
120
|
+
### --god
|
121
|
+
|
122
|
+
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.
|
123
|
+
|
124
|
+
For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use --god flag
|
125
|
+
|
126
|
+
### --with-index
|
127
|
+
|
128
|
+
By default no master index views get produced. Use this flag to produce an index view.
|
129
|
+
|
130
|
+
The index views simply include the _list partial but pass them a query to use:
|
131
|
+
|
132
|
+
`= render partial: "list", locals: {things: Thing.order("created_at DESC").page(1)}`
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
# TROUBLESHOOTING
|
142
|
+
|
143
|
+
## NoMethodError in HellosController#index undefined method `authenticate_user!' for #<HellosController:0x00007fcc2decf828> Did you mean? authenticate_with_http_digest
|
144
|
+
|
145
|
+
|
146
|
+
--> Install Devise
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
## Uncaught ReferenceError: $ is not defined
|
151
|
+
|
152
|
+
--> Install Jquery. Here's a good link: https://www.botreetechnologies.com/blog/introducing-jquery-in-rails-6-using-webpacker
|
153
|
+
|
154
|
+
Be sure to 1) add with Yark, 2) Modify environment.js, 3) Modify application.js
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
## Nothing happens after you install jQuery
|
159
|
+
|
160
|
+
--> Install Rails UJS
|
161
|
+
`yarn add @rails/ujs`
|
162
|
+
|
163
|
+
And add to config/webpack/environment.js
|
164
|
+
|
165
|
+
```
|
166
|
+
const webpack = require('webpack')
|
167
|
+
environment.plugins.prepend('Provide',
|
168
|
+
new webpack.ProvidePlugin({
|
169
|
+
$: 'jquery/src/jquery',
|
170
|
+
jQuery: 'jquery/src/jquery',
|
171
|
+
Rails: ['@rails/ujs']
|
172
|
+
})
|
173
|
+
)
|
174
|
+
module.exports = environment
|
175
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'CommonCoreJs'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link_directory ../stylesheets/common_core_js .css
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
<% if object.errors.any? %>
|
10
10
|
$(".flash-notices").html("<%= j render 'layouts/flash_notices' %>");
|
11
|
-
$("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-form").html("<%= j render(partial: '
|
11
|
+
$("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-form").html("<%= j render(partial: '#{controller.namespace}errors', locals: {resource: object}) %>")
|
12
12
|
$("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-form").append("<%= j render(partial: "new", locals: { singular.to_sym => object}) %><i class='fa fa-times-circle fa-2x' data-name='<%=singular%>' data-role='close-button' />").slideDown();
|
13
13
|
<% else %>
|
14
14
|
$("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-form").slideUp();
|
@@ -7,5 +7,5 @@ $(".<%= singular %>-list table tr[data-id=<%= object.id %>]").fadeOut(750,functi
|
|
7
7
|
|
8
8
|
<% else %>
|
9
9
|
$(".flash-notices").html("<%= j render 'layouts/flash_notices' %>");
|
10
|
-
$(".<%= singular %>-list").html("<%= j render(partial: '
|
10
|
+
$(".<%= singular %>-list").html("<%= j render(partial: '#{controller.namespace}errors', locals: {resource: object}) %><br/<%= j render partial: "list", locals: {plural.to_sym => all_objects} %>")
|
11
11
|
<% end %>
|
@@ -1 +1 @@
|
|
1
|
-
$('.<%= singular %>-list').html("<%= j render partial: "
|
1
|
+
$('.<%= singular %>-list').html("<%= j render partial: "#{controller.namespace}#{plural}/list", locals: {plural.to_sym => objects} %>")
|
@@ -2,8 +2,8 @@
|
|
2
2
|
New
|
3
3
|
= singular.titlecase
|
4
4
|
|
5
|
-
= form_with model: object, url: url, method: "post" do |f|
|
6
|
-
= render partial: "
|
5
|
+
= form_with model: object, url: url, method: "post", remote: true do |f|
|
6
|
+
= render partial: "#{controller.namespace}#{plural}/form", locals: {singular.to_sym => object, f: f}
|
7
7
|
|
8
8
|
.row
|
9
9
|
.col-md-12
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% if object.errors.any? %>
|
2
2
|
<% pass_through_locals ||= {} %>
|
3
|
-
$(".<%= singular %>-table tr[data-id=<%= object.id %>][data-edit='true']").html("<%= j render(partial: '
|
3
|
+
$(".<%= singular %>-table tr[data-id=<%= object.id %>][data-edit='true']").html("<%= j render(partial: '#{controller.namespace}errors', locals: {resource: object}) %><%= j render partial: 'edit', locals: {singular.to_sym => object, url: url, colspan: controller.default_colspan}.merge(pass_through_locals || {}) %>")
|
4
4
|
$(".flash-notices").html("<%= j render 'layouts/flash_notices' %>");
|
5
5
|
<% else %>
|
6
6
|
$(".<%= singular %>-table tr[data-id=<%= object.id %>]:not([data-edit='true'])").replaceWith("<%= j render partial: 'line', locals: {singular.to_sym => object } %>").fadeIn()
|
data/config/routes.rb
ADDED
data/lib/common_core_js.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
puts "*** Loading CommongCoreJS .........."
|
1
|
+
require "common_core_js/engine"
|
4
2
|
|
5
3
|
require 'kaminari'
|
6
4
|
require 'haml-rails'
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
|
7
|
+
module CommonCoreJs
|
8
|
+
# Your code goes here...
|
9
|
+
end
|
@@ -75,7 +75,7 @@ module CommonCore
|
|
75
75
|
|
76
76
|
|
77
77
|
|
78
|
-
if @auth_identifier.nil?
|
78
|
+
if @auth_identifier.nil? && !@auth.nil?
|
79
79
|
@auth_identifier = @auth.gsub("current_", "")
|
80
80
|
end
|
81
81
|
|
@@ -129,7 +129,7 @@ module CommonCore
|
|
129
129
|
|
130
130
|
|
131
131
|
def path_helper
|
132
|
-
"#{@namespace+"_" if @namespace}#{(@nested_args.join("_") + "_" if @nested_args.any?)}#{
|
132
|
+
"#{@namespace+"_" if @namespace}#{(@nested_args.join("_") + "_" if @nested_args.any?)}#{singular}_path"
|
133
133
|
end
|
134
134
|
|
135
135
|
|
@@ -156,13 +156,13 @@ module CommonCore
|
|
156
156
|
|
157
157
|
def object_scope
|
158
158
|
if @auth
|
159
|
-
if @nested_args.
|
160
|
-
@auth
|
159
|
+
if @nested_args.none?
|
160
|
+
@auth + ".#{plural}"
|
161
161
|
else
|
162
|
-
"@" + @nested_args.last + "
|
162
|
+
"@" + @nested_args.last + ".#{plural}"
|
163
163
|
end
|
164
164
|
else
|
165
|
-
|
165
|
+
@singular_class
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
@@ -213,10 +213,22 @@ module CommonCore
|
|
213
213
|
|
214
214
|
def create_merge_params
|
215
215
|
if @auth
|
216
|
-
"
|
216
|
+
"#{@auth_identifier}: #{@auth}"
|
217
217
|
end
|
218
218
|
end
|
219
219
|
|
220
|
+
|
221
|
+
|
222
|
+
def model_has_strings?
|
223
|
+
false
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
def model_search_fields # an array of fields we can search on
|
228
|
+
[]
|
229
|
+
end
|
230
|
+
|
231
|
+
|
220
232
|
private # thor does something fancy like sending the class all of its own methods during some strange run sequence
|
221
233
|
# does not like public methods
|
222
234
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
= link_to "New <%= singular.gsub('_',' ') %>", <%= path_helper %>(<%= nested_arity_for_path %>), disable_with: "Loading...", remote: true, class: "new-<%= singular %>-button btn btn-primary pull-right"
|
2
|
+
= link_to "New <%= singular.gsub('_',' ') %>", new_<%= path_helper %>(<%= nested_arity_for_path %>), disable_with: "Loading...", remote: true, class: "new-<%= singular %>-button btn btn-primary pull-right"
|
3
3
|
|
4
4
|
.clearfix
|
5
5
|
.new-<%= singular %>-form{style: "display: none; position: relative;"}
|
@@ -1 +1,3 @@
|
|
1
|
-
= render partial: "common/common_new_form", locals: {singular: '<%= singular %>', plural: "<%= plural %>", object: @<%= singular %>, url: <%= path_helper %>(<%= nested_objects_arity %>)}
|
1
|
+
= render partial: "common/common_new_form", locals: {singular: '<%= singular %>', plural: "<%= plural %>", object: @<%= singular %>, url: new_<%= path_helper %>(<%= nested_objects_arity %>)}
|
2
|
+
|
3
|
+
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class <%= controller_class_name %> < ApplicationController
|
2
|
-
<% unless @auth_identifier.
|
2
|
+
<% unless @auth_identifier.nil? %>
|
3
3
|
before_action :authenticate_<%= auth_identifier %>!
|
4
4
|
|
5
5
|
<% end %>
|
@@ -20,12 +20,11 @@ class <%= controller_class_name %> < ApplicationController
|
|
20
20
|
end<% end %> <% end %>
|
21
21
|
|
22
22
|
def load_<%= singular_name %>
|
23
|
-
@<%= singular_name %> = <%=
|
23
|
+
@<%= singular_name %> = <%= object_scope %>.find(params[:id])
|
24
24
|
end
|
25
25
|
|
26
26
|
def index
|
27
|
-
@<%= plural_name %> = <%=
|
28
|
-
.page(params[:page])
|
27
|
+
@<%= plural_name %> = <%= object_scope %><% if model_has_strings? %>.where(<%=class_name %>.arel_table[:email].matches("%#{@__general_string}%"))<% end %>.page(params[:page])
|
29
28
|
|
30
29
|
respond_to do |format|
|
31
30
|
format.js<% if @with_index %>
|
@@ -34,14 +33,14 @@ class <%= controller_class_name %> < ApplicationController
|
|
34
33
|
end
|
35
34
|
|
36
35
|
def new
|
37
|
-
@<%= singular_name %> = <%= class_name %>.new(
|
36
|
+
@<%= singular_name %> = <%= class_name %>.new(<%= create_merge_params %>)
|
38
37
|
respond_to do |format|
|
39
38
|
format.js
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
43
42
|
def create
|
44
|
-
@<%=singular_name %> = <%=class_name %>.create(<%=singular_name %>_params<%= create_merge_params %>)
|
43
|
+
@<%=singular_name %> = <%=class_name %>.create(<%=singular_name %>_params<% if !create_merge_params.empty? %>.merge!(<%= create_merge_params %>)<%end%>)
|
45
44
|
respond_to do |format|
|
46
45
|
if @<%= singular_name %>.save
|
47
46
|
format.js
|
@@ -93,6 +92,20 @@ class <%= controller_class_name %> < ApplicationController
|
|
93
92
|
def default_colspan
|
94
93
|
<%= @default_colspan %>
|
95
94
|
end
|
95
|
+
|
96
|
+
def namespace
|
97
|
+
<% if @namespace %>
|
98
|
+
"<%= @namespace %>/"
|
99
|
+
<% else %>
|
100
|
+
""
|
101
|
+
<% end %>
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
def common_scope
|
106
|
+
@nested_args
|
107
|
+
end
|
108
|
+
|
96
109
|
end
|
97
110
|
|
98
111
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: common_core_js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Fleetwood-Boldt
|
@@ -10,6 +10,26 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.3
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 6.0.3.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 6.0.3
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 6.0.3.2
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: kaminari
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,7 +96,16 @@ executables: []
|
|
76
96
|
extensions: []
|
77
97
|
extra_rdoc_files: []
|
78
98
|
files:
|
79
|
-
-
|
99
|
+
- LICENSE
|
100
|
+
- README.md
|
101
|
+
- Rakefile
|
102
|
+
- app/assets/config/common_core_js_manifest.js
|
103
|
+
- app/assets/stylesheets/common_core_js/application.css
|
104
|
+
- app/controllers/common_core_js/application_controller.rb
|
105
|
+
- app/helpers/common_core_js/application_helper.rb
|
106
|
+
- app/jobs/common_core_js/application_job.rb
|
107
|
+
- app/mailers/common_core_js/application_mailer.rb
|
108
|
+
- app/models/common_core_js/application_record.rb
|
80
109
|
- app/views/common/_common_create.js.erb
|
81
110
|
- app/views/common/_common_destroy.js.erb
|
82
111
|
- app/views/common/_common_edit.js.erb
|
@@ -86,8 +115,11 @@ files:
|
|
86
115
|
- app/views/common/_common_new_form.haml
|
87
116
|
- app/views/common/_common_show_form.haml
|
88
117
|
- app/views/common/_common_update.js.erb
|
89
|
-
-
|
118
|
+
- app/views/layouts/common_core_js/application.html.erb
|
119
|
+
- config/routes.rb
|
90
120
|
- lib/common_core_js.rb
|
121
|
+
- lib/common_core_js/engine.rb
|
122
|
+
- lib/common_core_js/version.rb
|
91
123
|
- lib/generators/common_core/USAGE
|
92
124
|
- lib/generators/common_core/erb/scaffold/common_core_scaffold_generator.rb
|
93
125
|
- lib/generators/common_core/scaffold_generator.rb
|
@@ -103,6 +135,7 @@ files:
|
|
103
135
|
- lib/generators/common_core/templates/index.js.erb
|
104
136
|
- lib/generators/common_core/templates/new.js.erb
|
105
137
|
- lib/generators/common_core/templates/update.js.erb
|
138
|
+
- lib/tasks/common_core_js_tasks.rake
|
106
139
|
- lib/version.rb
|
107
140
|
homepage: http://rubygems.org/gems/common-core-js
|
108
141
|
licenses:
|
@@ -119,7 +152,6 @@ post_install_message: "---------------------------------------------\nWelcome to
|
|
119
152
|
rdoc_options: []
|
120
153
|
require_paths:
|
121
154
|
- lib
|
122
|
-
- app
|
123
155
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
156
|
requirements:
|
125
157
|
- - ">="
|
@@ -127,9 +159,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
159
|
version: '0'
|
128
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
161
|
requirements:
|
130
|
-
- - "
|
162
|
+
- - ">="
|
131
163
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
164
|
+
version: '0'
|
133
165
|
requirements: []
|
134
166
|
rubygems_version: 3.0.3
|
135
167
|
signing_key:
|
data/lib/.DS_Store
DELETED
Binary file
|