scaffold_plus 1.4.1 → 1.4.2

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
  SHA1:
3
- metadata.gz: c4aab6e083182126fb602ed441d287d0c41acedb
4
- data.tar.gz: 839075341d53fcd54653600148f5b3a30c4de7eb
3
+ metadata.gz: dbdd8a87ff690f0bfa137df59728909141186200
4
+ data.tar.gz: 03705405a7d01856315b3d8370fa884c389ae672
5
5
  SHA512:
6
- metadata.gz: f26d80e516a8d9299e94dabd2802c8c8891176fb02295e73af0445ea7eb393c01997108f46f53e7dfc2a2eb78e5d4d2eb53bf61d7bee0eaf294c22b123c97b45
7
- data.tar.gz: b30579ce6a93d3631892273291af6e6f6a6c36d724255e4ecd6970c682caf8c33d8db2f13dfe49198943634beb790063b2269841ca6e212e6a1668d3bc567636
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
- text << " accepts_nested_attributes_for :#{children}\n" if options[:nested].present?
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"
@@ -1,3 +1,3 @@
1
1
  module ScaffoldPlus
2
- VERSION = "1.4.1"
2
+ VERSION = "1.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scaffold_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volker Wiegand