freeform 1.0.0 → 1.0.1
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.
- data/Gemfile.lock +1 -1
- data/lib/freeform/form/nested.rb +8 -3
- data/lib/freeform/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +10264 -0
- data/spec/form/nested_spec.rb +70 -16
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/freeform/form/nested.rb
CHANGED
@@ -34,7 +34,9 @@ module FreeForm
|
|
34
34
|
|
35
35
|
# Example: form.addresses will return all nested address forms
|
36
36
|
define_method(:"#{attribute}") do
|
37
|
-
|
37
|
+
value = instance_variable_get("@nested_#{attribute}")
|
38
|
+
value ||= []
|
39
|
+
instance_variable_set("@nested_#{attribute}", value)
|
38
40
|
end
|
39
41
|
|
40
42
|
# Example: form.build_addresses (optional custom initializer)
|
@@ -53,8 +55,11 @@ module FreeForm
|
|
53
55
|
|
54
56
|
# Build new model
|
55
57
|
form_model = form_class.new(initializer)
|
56
|
-
|
57
|
-
|
58
|
+
value = instance_variable_get("@nested_#{attribute}")
|
59
|
+
value ||= []
|
60
|
+
value << form_model
|
61
|
+
instance_variable_set("@nested_#{attribute}", value)
|
62
|
+
|
58
63
|
form_model
|
59
64
|
end
|
60
65
|
alias_method :"build_#{singularized_attribute}", :"build_#{attribute}"
|
data/lib/freeform/version.rb
CHANGED
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|