bullet_train-super_scaffolding 1.4.0 → 1.4.1

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: 261d7f697e72bdba89678e9a1e18dcfcea77a98d1662fdc31e585361e6f278f6
4
- data.tar.gz: 44f8a1cb83b867805a4b7397eff55f7bccf28e7897a500ef9615b92df8729a27
3
+ metadata.gz: 485420db9c25005cf70ac8fcbb71bdbd4dadae7ff44f92f8a6ddfaee58b895d4
4
+ data.tar.gz: af128caccce76aea17853c4c152311df781c2dcc807ba1d8aad599fd7806d6d1
5
5
  SHA512:
6
- metadata.gz: 462548d87a9c8b5a7ecb190985b724e69ca17b65aa4213d3c5a45fba87d9ef0360ea762dca60ac6a96f22de3446b9c2ba2a8000895f99223ed2840b2319eec57
7
- data.tar.gz: 63fb92b8b6dc4523f5fc9f9535b82b7f286fb9d4a48bfb43f913c6e7214a217a48a3a3fc4122e56dd20d3ce59cbb0fba054a91d8e85431d468e530f38cb0115e
6
+ metadata.gz: 6d009f66dafdac6748fb16b04220187353f508c7688542c68898d10cb6f91206948cb73b8e262c55716381bc3cac705aeb4f4774f6d7624cfdacafc7eaaf2e58
7
+ data.tar.gz: ebd80b91923bf8e3549dcc20047f28656285ee493dda4a560a6382a980149dd44c3628a03385f0987ca74d1810c565c4c9340d9a286e0be16d62bb9a19401af0
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.4.0"
3
+ VERSION = "1.4.1"
4
4
  end
5
5
  end
@@ -64,8 +64,14 @@ def check_required_options_for_attributes(scaffolding_type, attributes, child, p
64
64
 
65
65
  attribute_options[:class_name] ||= name_without_id.classify
66
66
 
67
- file_name = "app/models/#{attribute_options[:class_name].underscore}.rb"
68
- unless File.exist?(file_name)
67
+ file_name = Dir.glob("app/models/**/*.rb").find { |model| model.match?(/#{attribute_options[:class_name].underscore}\.rb/) } || ""
68
+
69
+ # If a model is namespaced, the parent's model file might exist under
70
+ # `app/models/`, but sometimes these files are modules that resolve
71
+ # table names by providing a prefix as opposed to an actual ApplicationRecord.
72
+ # This check ensures that the _id attribute really is a model.
73
+ is_active_record_class = attribute_options[:class_name].constantize.ancestors.include?(ActiveRecord::Base)
74
+ unless File.exist?(file_name) && is_active_record_class
69
75
  puts ""
70
76
  puts "Attributes that end with `_id` or `_ids` trigger awesome, powerful magic in Super Scaffolding. However, because no `#{attribute_options[:class_name]}` class was found defined in `#{file_name}`, you'll need to specify a `class_name` that exists to let us know what model class is on the other side of the association, like so:".red
71
77
  puts ""
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-super_scaffolding
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-08 00:00:00.000000000 Z
11
+ date: 2023-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard