bullet_train-super_scaffolding 1.3.25 → 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: 4edc8d1768ad95b11223504d7208df2c04d5944b901686e707b55e95b63d5d70
4
- data.tar.gz: 33895a551f0de25018b16d5eb7936abb2106e4faa8881c154e446b24eed10818
3
+ metadata.gz: 485420db9c25005cf70ac8fcbb71bdbd4dadae7ff44f92f8a6ddfaee58b895d4
4
+ data.tar.gz: af128caccce76aea17853c4c152311df781c2dcc807ba1d8aad599fd7806d6d1
5
5
  SHA512:
6
- metadata.gz: faa965190ccca41fcc80460ed3b563d75957d502b9cee98cb938f0818bc3b0db3baf9fc8406b72a57393ca4663fd5d218472909767fc8cb0f5e6c98dd95c26dd
7
- data.tar.gz: 545373c5b53ef717fae804a05c54d6a6c6947b755151234ec1325ec61d518260bc8b83c4806d30dd52ceab4dc292a4682d8b0d40e8316e8ed30e53a779efdf3a
6
+ metadata.gz: 6d009f66dafdac6748fb16b04220187353f508c7688542c68898d10cb6f91206948cb73b8e262c55716381bc3cac705aeb4f4774f6d7624cfdacafc7eaaf2e58
7
+ data.tar.gz: ebd80b91923bf8e3549dcc20047f28656285ee493dda4a560a6382a980149dd44c3628a03385f0987ca74d1810c565c4c9340d9a286e0be16d62bb9a19401af0
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.3.25"
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.3.25
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