scaffold_plus 2.1.2 → 2.1.3
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: 8708dc46850e0461defb7300d245701316cf8ebb
|
4
|
+
data.tar.gz: 890e0dd4a202e7266e140a8d260ac02dd85ed6f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c87225f56c51195d16dd58a3851d36a358a1d93559adf4b56de652a36e39ffe634bfa3d2fff09c70d001b1bfdab1784136f85f98abd1ccee458623d4b9dbe4f7
|
7
|
+
data.tar.gz: 3964f33ce1a8c2a227cc3c5639e6310e66c1289f2196ca80e3aeb44387c9ea6f9efd4fcfb25f888c7b94786931b9d27bba6c43e1d220195aa3829fd134cdf9eb
|
@@ -60,7 +60,7 @@ module ScaffoldPlus
|
|
60
60
|
text << ", dependent: :#{dependent}" if options.dependent.present?
|
61
61
|
text << "\n"
|
62
62
|
if options.nested.present?
|
63
|
-
text << " accepts_nested_attributes_for :#{children}\n"
|
63
|
+
text << " accepts_nested_attributes_for :#{children}, allow_destroy: true, reject_if: :all_blank\n"
|
64
64
|
end
|
65
65
|
text << "\n" if after_array.include?(name)
|
66
66
|
text
|
@@ -50,9 +50,9 @@ module ScaffoldPlus
|
|
50
50
|
text = before_array.include?(name) ? "\n" : ""
|
51
51
|
text << " has_one :#{child}"
|
52
52
|
text << ", inverse_of: :#{name}" if options.inverse?
|
53
|
-
text << ", dependent: :#{dependent}" if options.dependent
|
53
|
+
text << ", dependent: :#{dependent}" if options.dependent.present?
|
54
54
|
text << "\n"
|
55
|
-
if options.nested
|
55
|
+
if options.nested.present?
|
56
56
|
text << " accepts_nested_attributes_for :#{child}, allow_destroy: true\n"
|
57
57
|
end
|
58
58
|
text << "\n" if after_array.include?(name)
|
@@ -77,6 +77,7 @@ module ScaffoldPlus
|
|
77
77
|
list = options.nested.map{|n| ":#{n}"}.join(', ')
|
78
78
|
text = "#{child}_attributes: [ #{list} ]"
|
79
79
|
file = "app/controllers/#{table_name}_controller.rb"
|
80
|
+
return unless File.exist?(file)
|
80
81
|
gsub_file file, /(permit\(.*)\)/, "\\1, #{text})"
|
81
82
|
# Special case: no previous permit
|
82
83
|
gsub_file file, /^(\s*params)\[:#{name}\]$/, "\\1.require(:#{name}).permit(#{text})"
|
@@ -86,6 +87,7 @@ module ScaffoldPlus
|
|
86
87
|
return unless options.permit?
|
87
88
|
text = ":#{name}_id"
|
88
89
|
file = "app/controllers/#{child.pluralize}_controller.rb"
|
90
|
+
return unless File.exist?(file)
|
89
91
|
gsub_file file, /(permit\(.*)\)/, "\\1, #{text})"
|
90
92
|
# Special case: no previous permit
|
91
93
|
gsub_file file, /^(\s*params)\[:#{name}\]$/, "\\1.require(:#{name}).permit(#{text})"
|
@@ -95,16 +97,20 @@ module ScaffoldPlus
|
|
95
97
|
return unless options.route?
|
96
98
|
children = child.pluralize
|
97
99
|
file = "app/controllers/#{children}_controller.rb"
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
if File.exist?(file)
|
101
|
+
gsub_file file, /GET .#{children}.new$/ do |match|
|
102
|
+
match = "GET /#{table_name}/:id/#{children}/new"
|
103
|
+
end
|
104
|
+
gsub_file file, /^ @#{child} = #{child.camelize}.new$/ do |match|
|
105
|
+
match = " @#{name} = #{class_name}.find(params[:#{name}_id])\n" +
|
106
|
+
" @#{child} = @#{name}.#{children}.build"
|
107
|
+
end
|
104
108
|
end
|
105
109
|
file = "app/views/#{children}/_form.html.erb"
|
106
|
-
|
107
|
-
|
110
|
+
if File.exist?(file)
|
111
|
+
gsub_file file, /form_for\(@#{child}/ do |match|
|
112
|
+
match = "form_for([@#{name}, @#{child}]"
|
113
|
+
end
|
108
114
|
end
|
109
115
|
end
|
110
116
|
|
@@ -119,7 +125,7 @@ module ScaffoldPlus
|
|
119
125
|
end
|
120
126
|
|
121
127
|
def dependent
|
122
|
-
if options.dependent && options.dependent == "restrict"
|
128
|
+
if options.dependent.present? && options.dependent == "restrict"
|
123
129
|
"restrict_with_exception"
|
124
130
|
else
|
125
131
|
options.dependent
|
@@ -132,3 +138,5 @@ module ScaffoldPlus
|
|
132
138
|
end
|
133
139
|
end
|
134
140
|
end
|
141
|
+
|
142
|
+
# vim: set expandtab softtabstop=2 shiftwidth=2 autoindent :
|