common_core_js 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 809e054efc9ed1738f6c972124840343fb2053bc5b890b091ad4eb4a6872dd67
4
- data.tar.gz: c053c54714bd148a1b39f245a5b594f18954a1d72a6fb80b1ff94d9bd91e48c9
3
+ metadata.gz: 34c76baa6457d9e7647a7f703c72c4403f99c8e713a9edb3eeab161fa5087dfc
4
+ data.tar.gz: 168c7944599f096a31a35cec07168c019160dedf5d7713f271f5a4fab434bb4a
5
5
  SHA512:
6
- metadata.gz: 94a720a687266f365d01273c520481187455bb25d829a45fd05023936e38268c818fa9e3c577ad11ec980b4f3b94ed62912727e3d8d20ea2ce12bff1fa030ce8
7
- data.tar.gz: ac6abf280f684bbc16dfc504507a9edcc0679b9919dabd50ac89f159334eda9d959cd82444972f8d0e009809eb8d3f30eff9fd6ff6c6ecc0964834b99a3c4353
6
+ metadata.gz: bbc731908589e37e2bc52aa0a49fbe639acbcdbfe85a4a50faaae730d119bce2c9b80caeb09f0898f4f64dbcab1eedbb78c8f3e0eb899790e984ad64e9b2cfe0
7
+ data.tar.gz: de536f01b261a6d79e67c7ed1bb54a38df3cc3fc62b6053f38eab0c778eb5031e8e6638d6fd1ab8e5147335b4349d189dc491c3dd4430a88316bf6adfccbd206
data/README.md CHANGED
@@ -295,14 +295,27 @@ module.exports = environment
295
295
  ```
296
296
  # VERSION HISTORY
297
297
 
298
+ ## 0.4.7
299
+ - fixes some problems with display labeling through active record associations (was using a funky syntax for this)
300
+ - significant improvments to error messaging, like:
301
+
302
+ if you don't have a `current_user` and you don't specify an auth or auth_identifier (and you aren't using `--god` mode), helpful hint:
303
+
304
+ "*** Oops: It looks like is no association from current_user to a class called Invoice. 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."
305
+
306
+
307
+ If an association is on a model but the assocition has no field that can be used to display its name, you get this hint:
308
+
309
+ "*** Oops: Can't find any column to use as the display label for the account association on the Invoice model . TODO: Please implement just one of: 1) name, 2) to_label, 3) full_name, 4) display_name, or 5) email directly on your Account model (either as database field or model methods), then RERUN THIS GENERATOR. (If more than one is implemented, the field to use will be chosen based on the rank here, e.g., if name is present it will be used; if not, I will look for a to_label, etc)"
310
+
298
311
  ## 0.4.6
299
312
 
300
- - Fixes a bug with nested args
313
+ - Fixes a bug that would happen if you had no nested args
301
314
 
302
315
  ## 0.4.2 - 0.4.5 - Oct 2020
303
316
 
304
- - Not sure what I was doing here or why I made 3 released on the same day
305
- - Several bugfixes
317
+ - Not sure what I was doing here or why I made 3 releases on the same day(?)
318
+ - Several bugfixes happened during these iterations
306
319
 
307
320
  ## 0.3.0 - 0.4.1 - August 2020
308
321
 
@@ -1,3 +1,3 @@
1
1
  module CommonCoreJs
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.7'
3
3
  end
@@ -47,7 +47,7 @@ module CommonCore
47
47
  begin
48
48
  object = eval(class_name)
49
49
  rescue StandardError => e
50
- puts "Ooops... it looks like there is no object for #{class_name}. Please define the object + database table first."
50
+ puts "*** Oops: It looks like there is no object for #{class_name}. Please define the object + database table first."
51
51
  exit
52
52
  end
53
53
 
@@ -68,7 +68,6 @@ module CommonCore
68
68
 
69
69
  args[1..-1].each do |a|
70
70
  var_name, var_value = a.split("=")
71
- puts var_name
72
71
  case (var_name)
73
72
 
74
73
  when "plural"
@@ -108,7 +107,7 @@ module CommonCore
108
107
  end
109
108
 
110
109
  if @specs_only && @no_specs
111
- puts "oops… you seem to have specified both the --specs-only flag and --no-specs flags. this doesn't make any sense, so I am aborting. sorry."
110
+ puts "*** Oops: You seem to have specified both the --specs-only flag and --no-specs flags. this doesn't make any sense, so I am aborting. sorry."
112
111
  exit
113
112
  end
114
113
 
@@ -157,7 +156,11 @@ module CommonCore
157
156
  if assoc
158
157
  ownership_field = assoc.name.to_s + "_id"
159
158
  else
160
- puts "Ooops... it looks like is no association for #{@object_owner_sym} on #{singular_class} "
159
+ if @auth
160
+ puts "*** 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."
161
+ else
162
+ puts "*** Oops: god mode could not find the association(?). something is wrong."
163
+ end
161
164
  exit
162
165
  end
163
166
  end
@@ -449,26 +452,27 @@ module CommonCore
449
452
  puts "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
450
453
  exit
451
454
  end
452
- assoc_class_name = eval("#{singular_class}.reflect_on_association(:#{assoc_name})").class_name
453
455
 
454
- if assoc.active_record.column_names.include?("name")
456
+
457
+ assoc_class = eval(assoc.class_name)
458
+
459
+ if assoc_class.column_names.include?("name")
455
460
  display_column = "name"
456
- elsif assoc.active_record.column_names.include?("to_label")
461
+ elsif assoc_class.column_names.include?("to_label")
457
462
  display_column = "to_label"
458
- elsif assoc.active_record.column_names.include?("full_name")
463
+ elsif assoc_class.column_names.include?("full_name")
459
464
  display_column = "full_name"
460
- elsif assoc.active_record.column_names.include?("display_name")
465
+ elsif assoc_class.column_names.include?("display_name")
461
466
  display_column = "display_name"
462
- elsif assoc.active_record.column_names.include?("email")
467
+ elsif assoc_class.column_names.include?("email")
463
468
  display_column = "email"
464
469
  else
465
- puts "Can't find a display_column on {singular_class} object"
470
+ puts "*** Oops: Can't find any column to use as the display label for the #{assoc.name.to_s} association on the #{singular_class} model . TODO: Please implement just one of: 1) name, 2) to_label, 3) full_name, 4) display_name, or 5) email directly on your #{assoc.class_name} model (either as database field or model methods), then RERUN THIS GENERATOR. (If more than one is implemented, the field to use will be chosen based on the rank here, e.g., if name is present it will be used; if not, I will look for a to_label, etc)"
466
471
  end
467
472
 
468
-
469
473
  ".row
470
474
  %div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{assoc_name.to_s})}\"}
471
- = f.collection_select(:#{col.to_s}, #{assoc_class_name}.all, :id, :#{display_column}, {prompt: true, selected: @#{singular}.#{col.to_s} }, class: 'form-control')
475
+ = f.collection_select(:#{col.to_s}, #{assoc_class}.all, :id, :#{display_column}, {prompt: true, selected: @#{singular}.#{col.to_s} }, class: 'form-control')
472
476
  %label.small.form-text.text-muted
473
477
  #{col.to_s.humanize}"
474
478
 
@@ -549,18 +553,21 @@ module CommonCore
549
553
  exit
550
554
  end
551
555
 
552
- if assoc.active_record.column_names.include?("name")
556
+
557
+ assoc_class = eval(assoc.class_name)
558
+
559
+ if assoc_class.column_names.include?("name")
553
560
  display_column = "name"
554
- elsif assoc.active_record.column_names.include?("to_label")
561
+ elsif assoc_class.column_names.include?("to_label")
555
562
  display_column = "to_label"
556
- elsif assoc.active_record.column_names.include?("full_name")
563
+ elsif assoc_class.column_names.include?("full_name")
557
564
  display_column = "full_name"
558
- elsif assoc.active_record.column_names.include?("display_name")
565
+ elsif assoc_class.column_names.include?("display_name")
559
566
  display_column = "display_name"
560
- elsif assoc.active_record.column_names.include?("email")
567
+ elsif assoc_class.column_names.include?("email")
561
568
  display_column = "email"
562
569
  else
563
- puts "cant find any column to use as label for #{assoc.name.to_s}; any of name, to_labe, full_name, display_name, or email"
570
+ puts "*** Oops: Can't find any column to use as the display label for the #{assoc.name.to_s} association on the #{singular_class} model . TODO: Please implement just one of: 1) name, 2) to_label, 3) full_name, 4) display_name, or 5) email directly on your #{assoc.class_name} model (either as database field or model methods), then RERUN THIS GENERATOR. (If more than one is implemented, the field to use will be chosen based on the rank here, e.g., if name is present it will be used; if not, I will look for a to_label, etc)"
564
571
  end
565
572
 
566
573
  " %td
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.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  - !ruby/object:Gem::Version
230
230
  version: '0'
231
231
  requirements: []
232
- rubygems_version: 3.2.7
232
+ rubygems_version: 3.0.8
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: A gem build scaffolding.