scaffold_plus 1.7.11 → 1.7.12
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: 68e37c27b55f89e963f4135fc076b3e92c119ea8
|
4
|
+
data.tar.gz: 46e9036dd0ec3d01918448fa064bbc15be53d014
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|