scaffold_plus 1.7.11 → 1.7.12

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: 619beae71861d6f910411b93407982c26c4e903e
4
- data.tar.gz: 8b6ae2d013b7234d4f7b51544c625feb6100580b
3
+ metadata.gz: 68e37c27b55f89e963f4135fc076b3e92c119ea8
4
+ data.tar.gz: 46e9036dd0ec3d01918448fa064bbc15be53d014
5
5
  SHA512:
6
- metadata.gz: 85eea92393cf8e0feee61ce6850e22bd6d51227eb1e065f1022042c4d4aadcc98586e36bc13fcf377df2985612578bc0deba395679bf6be42276ce5c5daca9c5
7
- data.tar.gz: 17b3277c71716cd7ecf3bab9c1dfaa9b87850c0011c3921a211e2e9ac77b3665d4783f02a12b5f46ae8426a713eab63eb271813ad005d3b8c4aac3a8995da34b
6
+ metadata.gz: cd081c84f87ba43b0845affee828c8f448444d9a2d16759cee0be65f383afeecc531799259ae8b2b1c3dc6218b50a2a446fb8c1935b166544ee28d70a8c6f0cb
7
+ data.tar.gz: 3c655044bbe338171fceb4c8406f28dd813a23a98f384f264a6cd2a7549d66ac5e1822ec75e04ac26711e98a081197b4d9f07900cb56e0e59f0cc1eb3d10a40e
@@ -14,6 +14,8 @@ module ScaffoldPlus
14
14
  desc: 'Create a migration for added attributes'
15
15
  class_option :address, type: :boolean, default: true,
16
16
  desc: 'Add an address field to the migration'
17
+ class_option :permit, type: :boolean, default: false,
18
+ desc: 'Allow mass assignment for added attributes'
17
19
  class_option :before, type: :boolean, default: false,
18
20
  desc: 'Add a line before generated text in model'
19
21
  class_option :after, type: :boolean, default: false,
@@ -58,6 +60,16 @@ module ScaffoldPlus
58
60
  inject_into_class file, class_name, lines.join("\n")
59
61
  end
60
62
 
63
+ def update_controller
64
+ return unless options.permit?
65
+ text = ":#{options.latitude}, :#{options.latitude}"
66
+ text << ":address, :country" if options.address?
67
+ file = "app/controllers/#{table_name}_controller.rb"
68
+ gsub_file file, /(permit\(.*)\)/, "\\1, #{text})"
69
+ # Special case: no previous permit
70
+ gsub_file file, /^(\s*params)\[:#{name}\]$/, "\\1.require(:#{name}).permit(#{text})"
71
+ end
72
+
61
73
  protected
62
74
 
63
75
  def migration_name
@@ -1,3 +1,3 @@
1
1
  module ScaffoldPlus
2
- VERSION = "1.7.11"
2
+ VERSION = "1.7.12"
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.7.11
4
+ version: 1.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volker Wiegand