scaffold_plus 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbdd8a87ff690f0bfa137df59728909141186200
|
4
|
+
data.tar.gz: 03705405a7d01856315b3d8370fa884c389ae672
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 316f2369bd8531ab12cc0f1d733e3411674e1b05fa4b63cd53caf507f9a9cf543610b9dc75dddb00bb2bb52bb61ed8df9fee37c1226f644b39670b2f9afbee8e
|
7
|
+
data.tar.gz: 6998c1f2bdc6cf87789fa0b930ef8636a10f749b86acc0cd7df50bb8339e5e66bd9ba701c6fcb1ad5372e426c8ee1857512e963857413c0323f6b411e703dc5b
|
@@ -12,6 +12,8 @@ module ScaffoldPlus
|
|
12
12
|
desc: 'Can be destroy, delete, or restrict'
|
13
13
|
class_option :nested, type: :array, banner: 'attribute [...]',
|
14
14
|
desc: 'Add accepts_nested_attributes_for (incl. whitelisting)'
|
15
|
+
class_option :foreign_key, type: :string,
|
16
|
+
desc: 'Set the name of the foreign key directly'
|
15
17
|
class_option :inverse, type: :boolean, default: false,
|
16
18
|
desc: 'Add inverse_of to both models'
|
17
19
|
class_option :counter, type: :boolean, default: false,
|
@@ -43,7 +45,9 @@ module ScaffoldPlus
|
|
43
45
|
text << ", inverse_of: :#{name}" if options.inverse?
|
44
46
|
text << ", dependent: :#{dependent}" if options[:dependent].present?
|
45
47
|
text << "\n"
|
46
|
-
|
48
|
+
if options[:nested].present?
|
49
|
+
text << " accepts_nested_attributes_for :#{children}\n"
|
50
|
+
end
|
47
51
|
text << "\n" if after_array.include?(name)
|
48
52
|
text
|
49
53
|
end
|
@@ -52,6 +56,9 @@ module ScaffoldPlus
|
|
52
56
|
inject_into_class "app/models/#{child}.rb", child.camelize do
|
53
57
|
text = before_array.include?(child) ? "\n" : ""
|
54
58
|
text << " belongs_to :#{name}"
|
59
|
+
if options[:foreign_key].present?
|
60
|
+
text << ", foreign_key: \"#{options[:foreign_key]}\""
|
61
|
+
end
|
55
62
|
text << ", inverse_of: :#{children}" if options.inverse?
|
56
63
|
text << ", counter_cache: true" if options.counter?
|
57
64
|
text << "\n"
|