bullet_train-super_scaffolding 1.7.8 → 1.7.10

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: cdff26709713bf9865d6f6b0953a39d1bf89c130fdc33b34f9c8552446faf8be
4
- data.tar.gz: 21c62af1f68c7a2722ec139384b84e1b0272381fa7a001a92c0da1e03affa616
3
+ metadata.gz: 1cb0c43b459719314294d6a24a43e7054faa3d5e6cb1df3984182dae0a282bef
4
+ data.tar.gz: ccaf9c746b32982475c90daadf370fadc1c2633ddf5c31ff81cda454fcf95d23
5
5
  SHA512:
6
- metadata.gz: 5b4befc476572c979cccb6cdc082b9545b6df670ec6d9cc467310e151f2a85c35453f975a1adc9b7e33c9bf0b92b273edef90d95bd860b1e0db568cf8ec7fb66
7
- data.tar.gz: 27fdd01e6f4b8a3bcbef0764d6044ba150832b3315b8622ed9844eee656a0da2a929d0c57100f3d994c8d8c498a5e656bf158ddbea91ef1f22fff5f9f7dde747
6
+ metadata.gz: a936d0fdf8d8845179cf12682c51d4ad6016ee7d1a8ab1661b3127ad5d75ee67caa9d1007fb793ee68e59e00d2641d6851902f133b483f0b98fccd7e24e24838
7
+ data.tar.gz: 7de0542e5f1e40660015e6188e1dd28b7fe35678153516b138f923e76cd60f16f3998914a3bbfc5acf5e197439e8f62afe175704bb270a375199fe9bd31dce80
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.7.8"
3
+ VERSION = "1.7.10"
4
4
  end
5
5
  end
@@ -139,11 +139,34 @@ def check_required_options_for_attributes(scaffolding_type, attributes, child, p
139
139
 
140
140
  file_name = Dir.glob("app/models/**/*.rb").find { |model| model.match?(/#{attribute_options[:class_name].underscore}\.rb/) } || ""
141
141
 
142
+ begin
143
+ class_name_constant = attribute_options[:class_name].constantize
144
+ rescue NameError
145
+ if attribute_options[:class_name] == child
146
+ puts ""
147
+ puts "You appear to be tryingo scaffold a model that references itself. Unfotunately this needs to be a two-step process.".red
148
+ puts "First you should generate the model without the reference, and then add the reference as a new field. For instance:".red
149
+ puts ""
150
+ puts " rails generate super_scaffold #{child}#{" " + parent if parent.present?}".red
151
+ puts " rails generate super_scaffold:field #{child} #{name}:#{type}".red
152
+ puts ""
153
+ puts "If `#{name}` is just a regular field and isn't backed by an ActiveRecord association, you can skip all this with the `{vanilla}` option, e.g.:".red
154
+ puts ""
155
+ puts " rails generate super_scaffold #{child}#{" " + parent if parent.present?} #{name}:#{type}{vanilla}".red
156
+ puts ""
157
+ exit
158
+ else
159
+ # We don't do anything special here because we'll end up triggering the error message below. A self-referential model
160
+ # is kind of a special case that's worth calling out specifically. If we just can't find the model the messaging below
161
+ # should be sufficient to get folks on the right track.
162
+ end
163
+ end
164
+
142
165
  # If a model is namespaced, the parent's model file might exist under
143
166
  # `app/models/`, but sometimes these files are modules that resolve
144
167
  # table names by providing a prefix as opposed to an actual ApplicationRecord.
145
168
  # This check ensures that the _id attribute really is a model.
146
- is_active_record_class = attribute_options[:class_name].constantize.ancestors.include?(ActiveRecord::Base)
169
+ is_active_record_class = class_name_constant&.ancestors&.include?(ActiveRecord::Base)
147
170
  unless File.exist?(file_name) && is_active_record_class
148
171
  puts ""
149
172
  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
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.7.8
4
+ version: 1.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-24 00:00:00.000000000 Z
11
+ date: 2024-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard